# Data Structure Questions and Answers-Uniform Binary Search

## Data Structure Questions and Answers-Uniform Binary Search

 Question 1
When is the uniform binary search an optimization over the usual binary search?
 A A table lookup is generally faster than an addition and a shift B Many searches will be performed on the same array C Many searches will be performed on several arrays of the same length D All of the mentioned
Question 1 Explanation:
Suitable for architectures such as Knuth's MIX and MMIX and this algorithm was proposed by Donald Knuth.

 Question 2
Which of the following is a suitable lookup table that can be used in the uniform binary search?(N is the number of elements in the array and the delta array is global)

public static void make....delta(int N) { int power = 1; int i = 0; do { int half = power; power <<= 1; delta[ipublic static void make....delta(int N) { int power = 0; int i = 0; do { int half = power; power <<= 1; delta[ipublic static void make....delta(int N) { int power = 1; int i = 0; do { int half = power; power >>= 1; delta[i

public static void make....delta(int N) { int power = 1; int i = 0; do { int half = power; power <<= 1; delta[iUPSC GS Questions answers Question 2 Explanation:  This provides a single lookup index and the values are dependent on the the number of elements(N) in the array.
 Question 3
Given delta[4] is a global array and number of elements in the sorted array is 10, what are the values in the delta array?
 A 4, 3, 1, 0 B 5, 3, 1, 0 C 4, 2, 1, 1 D 5, 2, 1, 1
Question 3 Explanation:
Trace with respect to the make....delta function, always note that the last element is always 0.

 Question 4
Choose the appropriate code snippet that performs uniform binary search.
 A public static int unisearch(int key) { int i = delta[0] - 1; int j = 0; while (true) { if  B public static int unisearch(int key) { int i = delta[1] - 1; int j = 0; while (true)  C public static int unisearch(int key) { int i = delta[0] - 1; int j = 0; while (true) { if ( D None of the mentioned