Which Of The Following Code Correctly Represent Exponential #516
Which of the following code correctly represent exponential 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 - Exponential Search - Quiz No.2.
Which of the following code correctly represent exponential search?
int expSearch(int arr[], int n, int x) { if (arr[0] == x) return 0; int i = 1; while (i < n && arr[i] <= x) i = i*2; return binarySearch(arr, i/2, min(i, n-1), x); //applies binary search in the calculated range }
int expSearch(int arr[], int n, int x) { if (arr[0] == x) return 0; int i = 1; while (i < n && arr[i] <= x) i = i*2; return binarySearch(arr, i, min(i, n-1), x); //applies binary search in the calculated range }
int expSearch(int arr[], int n, int x) { if (arr[0] == x) return 0; int i = 1; while (i < n && arr[i] <= x) i = i/2; return binarySearch(arr, i/2, min(i, n-1), x); //applies binary search in the calculated range }
int expSearch(int arr[], int n, int x) { if (arr[0] == x) return 0; int i = 1; while (i < n && arr[i] <= x) i = i*2; return binarySearch(arr, i/2, max(i, n-1), x); //applies binary search in the calculated range }
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