Note : Separate Input elements by Commas [0,1]
Binary Search is an efficient algorithm for finding a target value within a sorted array. It works by repeatedly dividing the search interval in half and comparing the target value to the middle element of the array.
Time Complexity:
O(log n) (the search space is halved with each iteration)
Extract Max: O(log n) (restructuring the heap after removing the root)
Peek Max: O(1) (accessing the root)
Space Complexity:
O(1) (iterative version) or O(log n) (recursive version due to call stack)
Binary Search is highly efficient and suitable for large datasets, but it requires the data to be sorted beforehand.