Font size
WorksheetsSorting Algorithms
Total questions: 14
Worksheet time: 16mins
Which of the following is not a stable sorting algorithm?
Bubble sort
Selection sort
Quick sort
None of these
Which of the following is/are in-place sorting algorithm(s)?
Selection sort
Bubble sort
Quick sort
Merge sort
The worst-case time complexity of a quick sort algorithm?
O(nlogn)
O(logn)
O(n^2)
O(n^2logn)
The no.of comparisons in first pass in bubble sort to sort n numbers is....?
n
n(n-1)/2
n-1
n^2
The maximum no.of swappings in first pass of selection sort to sort n numbers is....?
1
n(n-1)/2
n-1
n^2
In quick sort, based on key or pivot element position, the list is partitioned into how many sub-lists?
1
2
3
4
If the list is almost sorted, then which of the following algorithm gives the better performance?
Bubble sort
Selection sort
Quick sort
All of these
If the list is almost sorted, then which of the following algorithm is/are not suitable?
Bubble sort
Selection sort
Quick sort
All of these
In bubble sort, what will be the sequence of the following elements after 7 passes?
20 15 14 45 11 18 78 95
(a)
In bubble sort, what will be the sequence of the following elements after 1st pass?
2 1 4 45 11 18 78 95
(a)
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)
The no.of passes in selection sort to sort n numbers is .....?
n
n-1
n^2
logn
The no.of swapings in selection sort to sort n numbers is .....?
n
n-1
n^2
logn
Write C code to swap two integers a and b by using a temporary variable t?
(a)
