wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Sorting Algorithms

Total questions: 14

Worksheet time: 16mins

Name
Class
Date
1.

Which of the following is not a stable sorting algorithm?

a)

Bubble sort

b)

Selection sort

c)

Quick sort

d)

None of these

2.

Which of the following is/are in-place sorting algorithm(s)?

a)

Selection sort

b)

Bubble sort

c)

Quick sort

d)

Merge sort

3.

The worst-case time complexity of a quick sort algorithm?

a)

O(nlogn)

b)

O(logn)

c)

O(n^2)

d)

O(n^2logn)

4.

The no.of comparisons in first pass in bubble sort to sort n numbers is....?

a)

n

b)

n(n-1)/2

c)

n-1

d)

n^2

5.

The maximum no.of swappings in first pass of selection sort to sort n numbers is....?

a)

1

b)

n(n-1)/2

c)

n-1

d)

n^2

6.

In quick sort, based on key or pivot element position, the list is partitioned into how many sub-lists?

a)

1

b)

2

c)

3

d)

4

7.

If the list is almost sorted, then which of the following algorithm gives the better performance?

a)

Bubble sort

b)

Selection sort

c)

Quick sort

d)

All of these

8.

If the list is almost sorted, then which of the following algorithm is/are not suitable?

a)

Bubble sort

b)

Selection sort

c)

Quick sort

d)

All of these

9.

In bubble sort, what will be the sequence of the following elements after 7 passes?

20 15 14 45 11 18 78 95

(a)  

10.

In bubble sort, what will be the sequence of the following elements after 1st pass?

2 1 4 45 11 18 78 95

(a)  

11.

In selection sort, what will be the sequence of the following elements after 2nd pass?

8 6 3 7 63 4 10 103 61

(a)  

12.

The no.of passes in selection sort to sort n numbers is .....?

a)

n

b)

n-1

c)

n^2

d)

logn

13.

The no.of swapings in selection sort to sort n numbers is .....?

a)

n

b)

n-1

c)

n^2

d)

logn

14.

Write C code to swap two integers a and b by using a temporary variable t?

(a)