Choose Among The Following Code For An Iterative Binary Search #472
Choose among the following code for an iterative binary search.
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Searching - Binary Search Iterative - Quiz No.1.
Choose among the following code for an iterative binary search.
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high + low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid - 1; } else { high = mid + 1; } } return -1; }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high - low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid + 1; } else { high = mid - 1; } } return -1; }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high + low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid + 1; } else { high = mid - 1; } } return -1; }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high - low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid - 1; } else { high = mid + 1; } } return -1; }
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes