Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Understanding Search Algorithms

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the time complexity of linear search in the worst case?

a)

O(n)

b)

O(log n)

c)

O(n^2)

d)

O(1)

2.

Which of the following is a requirement for binary search to work?

a)

The data must be sorted.

b)

The data must be in pairs.

c)

The data must be unique.

d)

The data must be in ascending order.

3.

What is the average time complexity of binary search?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

4.

In which scenario is linear search preferred over binary search?

a)

When the dataset is small.

b)

When the data is sorted.

c)

When the data is unsorted.

d)

When searching for a specific value.

5.

What is the main advantage of binary search over linear search?

a)

Binary search requires unsorted data for optimal performance.

b)

Binary search is faster due to its O(log n) time complexity.

c)

Binary search is slower with O(n) time complexity.

d)

Linear search is more efficient for large datasets.

6.

How does the time complexity of linear search compare to that of binary search?

a)

Linear search is O(1) while binary search is O(n).

b)

Linear search is O(n^2) while binary search is O(n).

c)

Linear search is O(log n) while binary search is O(n).

d)

Linear search is O(n) while binary search is O(log n).

7.

What type of data structure is required for binary search?

a)

Sorted array or sorted list

b)

Linked list or tree structure

c)

Unsorted array or unsorted list

d)

Hash table or set

8.

Which algorithm is generally faster for large datasets, linear search or binary search?

a)

Binary search

b)

Sequential search

c)

Exponential search

d)

Jump search

9.

What is the best-case time complexity of linear search?

a)

O(n^2)

b)

O(n)

c)

O(1)

d)

O(log n)

10.

In a sorted array of 1000 elements, how many comparisons would binary search make in the worst case?

a)

20

b)

10

c)

15

d)

5