Data Structure Questions and Answers-Uniform Binary Search

 

 Buy/Download all MCQ Ebook   >>>Click Here<<<

Data Structure Questions and Answers-Uniform Binary Search

Click on any option to know the CORRECT ANSWERS

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
Puzzles Questions answers

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)
A

public 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 = 0; 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[i
D

public static void make....delta(int N) { int power = 1; int i = 0; do { int half = power; power <<= 1; delta[iEducation 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
Commerce Questions answers

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

Biology Questions answers

Question 4 Explanation: 
Unlike the usual binary search which a low, high and a mid variable and every time comparing the key with the mid value, the comparing index is obtained from the lookup delta table, choosing the left or right side of the array is same as with the normal binary search.

Question 5
What is the time complexity of uniform binary search?
A
O(nlogn)
B
O(logn)
C
O(n)
D
O(n2)
Aptitude test Questions answers

Question 5 Explanation: 
With every iteration we are dividing the array into two parts(though not equal halves), the complexity remains same as the normal binary search.

There are 5 questions to complete.

 

 Buy/Download all MCQ Ebook >>>CLICK HERE<<<