The following program contains any error.

def binarySearch(list, key):

    first = 0

    last = len(list) - 1 #statement 1

    while(first >= last): #statement 2

        mid = (first + last)//2

        if list[mid] == key:

            return mid #statement 3

        elif key > list[mid]:

            first = mid + 1

        elif key < list[mid]:

            last = mid - 1

    return -1 #statement 4

Identify the incorrect statement.

1

Statement 1

2
Statement 2
3
Statement 3
4
Statement 4

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation