• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

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

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!

Last Updated :
Share your thoughts in the comments