Given the pseudocode for performing Binary search in an array of elements sorted in ascending order. What operation must be implemented in the 3rd so that the execution of binary search is successful?
(A)
Else if x is greater than the middle element, then x can only lie in the right half subarray after the middle element. So we recursively search for the right
(B)
Else if x is greater than the middle element, then x can only lie in the left half subarray after the middle element. So we recursively search for left
(C)
None of the above
(D)
Else if x is less than the middle element, then x can only lie in the right half subarray after the middle element. So we recursively search for the right
Answer
Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!