Choose The Appropriate Code Snippet That Performs Uniform #480
Choose the appropriate code snippet that performs uniform 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 - Uniform Binary Search - Quiz No.1.
Choose the appropriate code snippet that performs uniform binary search.
public static int unisearch(int key) { int i = delta[0] - 1; int j = 0; while (true) { if (key == arr[i]) return i; else if (delta[j] == 0) return -1; else { if (key < arr[i]) i += delta[++j]; else i -= delta[++j]; } } }
public static int unisearch(int key) { int i = delta[1] - 1; int j = 0; while (true) { if (key == arr[i]) return i; else if (delta[j] == 0) return -1; else { if (key < arr[i]) i -= delta[++j]; else i += delta[++j]; } } }
public static int unisearch(int key) { int i = delta[0] - 1; int j = 0; while (true) { if (key == arr[i]) return i; else if (delta[j] == 0) return -1; else { if (key < arr[i]) i -= delta[++j]; else i += delta[++j]; } } }
public static int unisearch(int key) { int i = delta[0] - 1; int j = 0; while (true) { if (key == arr[i]) return i; else if (delta[j] == 0) return -1; else { if (key < arr[i]) i += delta[++j]; else i += delta[++j]; } } }
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