# Interview Questions on Binary Search Set 3

## This is my quiz series covering questions only on binary search. The level of these questions is that of a beginner. This is quiz no. 3 in this series.

Last Reviewed and Updated on February 7, 2020

## Quiz Questions

Each question has four choices. More than one options can be correct. When you have finished the quiz, click the button at the end of the questions to view the result, and the solutions and answers.

### Question 1

What is the best case efficiency of binary search?
A
O(n log n)
B
O(1)
C
O(log n)
D
O(n)
Soln.
Ans: B
The best case efficiency of binary search is O(1).

### Question 2

Which are the two principle criteria for selecting a hash function?
A
It should be easy and quick to compute
B
It should achieve a uniform distribution of keys in address space
C
Both A and B
D
None of them
Soln.
Ans: C
Two principle criteria in selecting a hash function are:
1. It should be easy and quick to compute.
2. It should achieve a uniform distribution of keys in address space.

### Question 3

What is the best case efficiency of binary search?
A
O(n log n)
B
O(1)
C
O(log n)
D
O(n)
Soln.
Ans: B
The best case efficiency of binary search is O(1).

### Question 4

The worst case efficiency of hash function is:
A
O(1)
B
O(n)
C
O(log n)
D
O(n log n)
Soln.
Ans: B
The worst case efficiency of hash function when poor hash function is used is O(n).

### Question 5

What is the best definition of a collision in a hash table?
A
Two entries are identical except for their keys.
B
Two entries with different data have the exact same key.
C
Two entries with different keys have the same exact hash value.
D
Two entries with the exact same key have different hash values.
Soln.
Ans: C
The situation in which hash function generates the same hash value for two or more keys is called collision.

### Question 6

Which type of data structure is used in binary search?
A
Tree
B
C
Array
D
None of them
Soln.
Ans: C

### Question 7

In which of the following hashing techniques, you apply a second hash function in case of a collision
A
Double Hashing
B
C
Linear Probing
D
Separate Probing
Soln.
Ans: A
Double Hashing

### Question 8

In hashing, conversion of the key to an address is done by a relation, which is known as ?
A
Hashing relation
B
Formula
C
Hashing Function
D
None of them
Soln.
Ans: C
In hashing, conversion of the key to an address is done by a relation, which is known as a Hashing Function

### Question 9

To apply binary search algorithm, you should ensure that the list to be searched is___________
A
Unsorted
B
Partially sorted
C
Sorted
D
all of them
Soln.
Ans: C
To apply binary search algorithm, you should ensure that the list to be searched is sorted list.

### Question 10

What is the worst case performance of binary search?
A
O(n log n)
B
O(log n)
C
O(1)
D
O(n)
Soln.
Ans: B
The worst case performance of binary search is O(log n).

## My C/C++ Videos on Youtube

Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.