Open In App

Infosys | Pseudocode Questions | Question 1

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?

  1. Middle element should be compared with x.
  2. If x and the middle element match, we return the middle index.
  3. _ _ _ _ _ _ _ _ _ _ _
  4. Else ( x is smaller than the middle element) recur for the left half

(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: (A)
Explanation:
Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :
Uncategorized