Consider the following Binary Search algorithm implemented in python. Choose the option that can replace the blanks (i) and (ii) respectively.

def binarySearch(list, key):

      first = 0

      last = len(list) - 1

      while(first <= last):

          mid = (first + last)//2

          if list[mid] == key:

               return mid

          elif key > list[mid]:

               ___________ (i)

          else:

               ___________ (ii)

      return -1

1
first = mid + 1 ,  last = mid + 1
2
first = mid - 1 ,  last = mid + 1
3
first = mid + 1 ,  last = mid - 1
4
first = mid - 1 ,  last = mid - 1

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation