wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Sorting

Total questions: 18

Worksheet time: 10mins

Name
Class
Date
1.

You have the following array:
[9,1,3,5,8,4]
What would the array look like after the first three iterations of the selection sort algorithm?

a)

[1,3,4,5,8,9]

b)

[1,9,3,5,8,4]

c)

[1,3,9,5,8,4]

d)

[1,3,9,4,8,5]

e)

[1,3,5,9,4,8]

2.

You have the following array:
[9,1,3,5,8,4]
What would the array look like after the first three iterations of the insertion sort algorithm (starting from the second element)?

a)

[1,9,3,5,8,4]

b)

[1,3,9,5,8,4]

c)

[1,3,5,8,9,4]

d)

[1,3,5,9,8,4]

e)

[1,3,4,5,8,9]

3.

You have the following array:
[9,1,3,5,8,4]
What would the array look like after the first five (actual) swaps of the bubble sort algorithm?

a)

[1,9,3,5,8,4]

b)

[1,3,5,9,8,4]

c)

[1,3,5,8,4,9]

d)

[1,3,9,5,8,4]

e)

[1,3,5,4,8,9]

4.

What will be the time complexity of using merge sort to order an array with a length of n?

a)

O(n^2)

b)

O(n)

c)

O(n log n)

d)

O(n^3/2)

5.

Suppose you want to use merge sort to order an array with a length of . As you already know, one of the phases of merge sort is the merging of two previously sorted subarrays. How would you estimate the number of "merging" steps in which a particular element participates?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n log n)

6.

What is the time complexity of using the heap sort algorithm to order an array with a length of n ?

a)

O(n)

b)

O(n^2)

c)

It depends on whether you need to order the elements in ascending or descending order.

d)

O(n log n)

7.

Suppose you have a heap with minimum priority. What is the time complexity of removing the minimum element from it?

a)

O(1)

b)

O(log n)

c)

O(n)

8.

Which of the following are the key factors the quicksort algorithm relies on?

a)

Selecting the pivot

b)

The number of subarrays produced by partitioning

c)

The partitioning mechanism

d)

The size of the input array

e)

The number of recursive calls

9.

Which of the following are the key properties of Hoare partitioning for quicksort (compared to Lomuto partitioning)?

a)

More iterations

b)

Fewer iterations

c)

More comparisons

d)

Fewer comparisons

e)

Fewer swaps

10.

What of the following can cause slight problems for quicksort (in terms of performance)?

a)

The presence of repeated elements in an array

b)

The presence of negative numbers in an array

c)

The presence of prime numbers in an array

11.

Which of the following statements are correct?

a)

Quicksort is unstable.

b)

Heapsort is unstable.

c)

Heapsort is unstable.

d)

Heapsort is "in-place."

e)

Heap sort is not "in-place."

12.

Which of the following statements is correct?

a)

Counting sort can only be used for string arrays.

b)

Counting sort can only be used for integer arrays.

c)

Counting sort can be used for both integer and string arrays.

13.
a)

b)

c)

d)

14.

Suppose you have the following array: [135, 521, 523, 621, 683, 191]
What will it look like after the second iteration of radix sort?

a)

[521, 523, 621, 135, 683, 191]

b)

[521, 621, 523, 683, 135, 191]

c)

[521, 191, 621, 523, 683, 135]

d)

[521, 621, 523, 135, 683, 191]

15.
a)

O(1)

b)

O(n long n)

c)

O(n)

d)

O(log n)

16.

For which of the following classes of functions is binary search applicable?

a)

Monotonic

b)

Monotonically ascending only

c)

Monotonically descending only

d)

Convex functions

17.

Find the median of the list [1, 4, 2, 6, 3, 7, 8].

(a)  

18.

What is the average-case time complexity of the QuickSelect algorithm?

a)

O(n^2)

b)

O(n)

c)

O(n long n)