wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Searching and Sorting

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

Choose a CORRECT statement about pivot in quick sort method.

a)

A pivot divides the list evenly.

b)

A pivot can be chosen randomly.

c)

A pivot is chosen by using a formula

d)

A pivot makes the searching method becomes slow

2.

Identify the INCORRECT statement about searching


i. Binary search starts by testing the largest data

ii. Linear search can be done for unsorted data only

iii. Linear search starts by testing data at the middle of list

iv. Binary search can be done for sorted homogeneous data

a)

i, ii and iii

b)

ii, iii and iv

c)

i, iii and iv

d)

i, ii, iii and iv

3.

Suppose a list is {2, 9, 5, 4, 8, 1}. After the first phase of bubble sort, the list becomes …

a)

2, 9, 5, 4, 8, 1

b)

2, 9, 5, 4, 1, 8

c)

2, 5, 9, 4, 8, 1

d)

2, 5, 4, 8, 1, 9

4.

Given a list is {7, 4, 5, 9, 8, 2, 1}. After the first phase of selection sort, the list becomes …

a)

1,2,4,9,8,5,7

b)

1,2,5,9,8,4,7

c)

1,4,5,9,8,2,7

d)

7,4,5,9,8,2,1

5.

If the number of records to be sorted is small, identify the suitable sorting to be used

a)

Quick sort

b)

Merge sort

c)

Selection sort

d)

Bubble sort

6.

The worst case occurs in linear search algorithm when ______________________

a)

Item is not in the array at all

b)

Item is somewhere in the middle of the array

c)

Item is the last element in the array or item is not there at all

d)

Item is the last element in the array

7.

Suppose we are sorting an array of eight integers using quick sort, and we have just finished the first partitioning with the array looking like this:

2 5 1 7 9 12 11 10

Identify the correct statement?

a)

Neither the 7 nor the 9 is the pivot.

b)

The pivot could be either the 7 or the 9.

c)

The pivot is not the 7, but it could be the 9.

d)

The pivot could be the 7, but it is not the 9.

8.

How many swaps needed to sort the following numbers using a selection sort.

5 ,1 , 12 , -5 , 16 , 2 ,12 , 14

a)

8

b)

6

c)

7

d)

5

9.

With a data set of 0,1,3,6,7,8,9


How many steps would a binary search take to find the value 8?

a)

2

b)

4

c)

3

d)

7

10.

Which sorting algorithm is more efficient with longer lists of data?

a)

Merge Sort

b)

Bubble Sort

c)

Both

d)

Neither

11.

Why might a sorting algorithm be needed before a search?

a)

Data is better when ordered

b)

Data always needs to be in order before searching

c)

The search algorithm may be in the code before the sorting algorithm

d)

The search algorithm may need the data to be in order

12.

What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?

a)

Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n^2)

b)

Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)

c)

Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn)

d)

Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn)

13.

Which of the following is NOT a stable sorting algorithm in its typical implementation.

a)

Insertion sort

b)

Bubble sort

c)

Merge sort

d)

Quick sort

e)

None

14.

You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?

a)

Heap Sort

b)

Merge Sort

c)

Quick Sort

d)

All of the above

15.

Identify the sorting algorithm that apply divide-and-conquer method.

a)

Linear Sort

b)

Merge Sort

c)

Heap Sort

d)

Binary Sort