Which Of The Following Code Correctly Represent Jump Search #495
Which of the following code correctly represent jump 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 - Jump Search - Quiz No.2.
Which of the following code correctly represent jump search?
int jumpSearch(int arr[], int x, int n) { int step = n*n; int prev = 0; while (arr[min(step, n)-1] < x) { prev = step; step += sqrt(n); if (prev >= n) return -1; } while (arr[prev] < x) { prev++; if (prev == min(step, n)) return -1; } if (arr[prev] == x) return prev; return -1; }
int jumpSearch(int arr[], int x, int n) { int step = sqrt(n); int prev = 0; while (arr[min(step, n)-1] < x) { prev = step; step += sqrt(n); if (prev >= n) return -1; } while (arr[prev] < x) { prev++; if (prev == min(step, n)) return -1; } if (arr[prev] == x) return prev; return -1; }
int jumpSearch(int arr[], int x, int n) { int step = sqrt(n); int prev = 0; while (arr[min(step, n)-1] < x) { prev = step; step += sqrt(n); if (prev == n) return -1; } while (arr[prev] < x) { prev++; if (prev == min(step, n)) return -1; } if (arr[prev] == x) return prev; return -1; }
int jumpSearch(int arr[], int x, int n) { int step = sqrt(n); int prev = 0; while (arr[min(step, n)-1] < x) { prev = step; step += sqrt(n); if (prev >= n) return -1; } while (arr[prev] > x) { prev++; if (prev == min(step, n)) return -1; } if (arr[prev] == x) return prev; 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