wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Searching Algorithms

Total questions: 26

Worksheet time: 16mins

Name
Class
Date
1.

Where is linear searching used?

a)

When the list has only a few elements

b)

When performing a single search in an unordered list

c)

Used all the time

d)

When the list has only a few elements and when performing a single search in an unordered list

2.

What is the best case complexity for linear search?

a)

O(nlogn)

b)

O(logn)

c)

O(n)

d)

O(1)

3.

What is the worst case complexity for linear search?

a)

O(nlogn)

b)

O(logn)

c)

O(n)

d)

O(1)

4.

Which of the following is a disadvantage of linear search?

a)

Requires more space

b)

Greater time complexities compared to other searching algorithms

c)

Not easy to understand

d)

Not easy to implement

5.

Which of the following is not an application of binary search?

a)

To find the lower/upper bound in an ordered sequence

b)

Searching for a word in a dictionary

c)

Debugging

d)

To search in unordered list

6.

Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are doneuntil the element is found using binary search?

a)

1

b)

2

c)

3

d)

4

7.

Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid values(corresponding array elements) generated in the first and second iterations using binary search?

a)

90 and 99

b)

90 and 100

c)

89 and 94

d)

94 and 99

8.

What is the time complexity of binary search with iteration?

a)

O(nlogn)

b)

O(logn)

c)

O(n)

d)

O(n2)

9.

Jump search is worse than linear search in terms of time complexity.

a)

True

b)

False

10.

Jump search has a worst case time complexity of O(n).

a)

True

b)

False

11.

Jump search algorithm requires which of the following condition to be true?

a)

array should be sorted

b)

array should not be sorted

c)

array should have a less than 64 elements

d)

array should be partially sorted

12.

Jumps are made in the jump search algorithm until

a)

element having value less than that of the required element is found

b)

element having value equal to the median of values of the array is found

c)

element having value greater than that of the required element is found

d)

middle element is found equal to the element being searched

13.

In Jump Search, which of the following steps is taken after finding an element having value greater than the element being searched?

a)

linear search takes place in the forward direction

b)

linear search takes place in the backward direction

c)

binary search takes place in the forward direction

d)

binary search takes place in a backward direction

14.

How many jumps will be made in the worst case of jump search (let block jumped=k)?

a)

n*k

b)

n/k

c)

k/n

d)

n+k

15.

What is the value of jump taken for maximum efficiency while implementing jump search?

a)

n/2

b)

n^2

c)

n^(1/2)

d)

log n

16.

Which of the following searching algorithm is fastest?

a)

jump search

b)

binary search

c)

linear search

d)

all are equally fast

17.

Which of the following is the most desirable condition for interpolation search?

a)

array should be sorted

b)

array should not be sorted but the values should be uniformly distributed

c)

array should have less than 64 elements

d)

array should be sorted and the values should be uniformly distributed

18.

Interpolation search is a variation of?

a)

Linear search

b)

Binary search

c)

Jump search

d)

Exponential search

19.

Interpolation search performs better than binary search when?

a)

array has uniformly distributed values but is not sorted

b)

array is sorted and has uniform distribution of values

c)

array is sorted but the values are not uniformly distributed

d)

array is not sorted

20.

In which of the following case jump search performs better than interpolation search?

a)

when array has uniformly distributed values but is not sorted

b)

when array is sorted and has uniform distribution of values

c)

when array is sorted but the values increases exponentially

d)

when array is not sorted

21.

What is the time complexity of interpolation search when the input array has uniformly distributed values and is sorted?

a)

O(n)

b)

O(log log n)

c)

O(n log n)

d)

O(log n)

22.

Which of the following searching algorithm is fastest when the input array is sorted and has uniformly distributed values?

a)

jump search

b)

exponential search

c)

binary search

d)

interpolation search

23.

Which of the following searching algorithm is fastest when the input array is sorted but has non uniformly distributed values?

a)

jump search

b)

linear search

c)

binary search

d)

interpolation search

24.

Which of the following searching algorithm is fastest when the input array is not sorted but has uniformly distributed values?

a)

jump search

b)

linear search

c)

binary search

d)

interpolation search

25.

What is the formula used for calculating the position in interpolation search?(x = element being searched, A[] = input array, low and high are the leftmost and rightmost index of A[] respectively)

a)

((x – A[low]) * (high – low)) / (A[high] – A[low])

b)

high + ((x – A[low]) * (high – low)) / (A[high] – A[low])

c)

low + ((x – A[low]) * (high – low)) / (A[high] – A[low])

d)

x + ((x – A[low]) * (high – low)) / (A[high] – A[low])

26.

Select the code snippet which performs unordered linear search iteratively?

a)

b)

c)

d)