WorksheetsSorting
Total questions: 18
Worksheet time: 10mins
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?
[1,3,4,5,8,9]
[1,9,3,5,8,4]
[1,3,9,5,8,4]
[1,3,9,4,8,5]
[1,3,5,9,4,8]
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)?
[1,9,3,5,8,4]
[1,3,9,5,8,4]
[1,3,5,8,9,4]
[1,3,5,9,8,4]
[1,3,4,5,8,9]
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?
[1,9,3,5,8,4]
[1,3,5,9,8,4]
[1,3,5,8,4,9]
[1,3,9,5,8,4]
[1,3,5,4,8,9]
What will be the time complexity of using merge sort to order an array with a length of n?
O(n^2)
O(n)
O(n log n)
O(n^3/2)
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?
O(1)
O(n)
O(log n)
O(n log n)
What is the time complexity of using the heap sort algorithm to order an array with a length of n ?
O(n)
O(n^2)
It depends on whether you need to order the elements in ascending or descending order.
O(n log n)
Suppose you have a heap with minimum priority. What is the time complexity of removing the minimum element from it?
O(1)
O(log n)
O(n)
Which of the following are the key factors the quicksort algorithm relies on?
Selecting the pivot
The number of subarrays produced by partitioning
The partitioning mechanism
The size of the input array
The number of recursive calls
Which of the following are the key properties of Hoare partitioning for quicksort (compared to Lomuto partitioning)?
More iterations
Fewer iterations
More comparisons
Fewer comparisons
Fewer swaps
What of the following can cause slight problems for quicksort (in terms of performance)?
The presence of repeated elements in an array
The presence of negative numbers in an array
The presence of prime numbers in an array
Which of the following statements are correct?
Quicksort is unstable.
Heapsort is unstable.
Heapsort is unstable.
Heapsort is "in-place."
Heap sort is not "in-place."
Which of the following statements is correct?
Counting sort can only be used for string arrays.
Counting sort can only be used for integer arrays.
Counting sort can be used for both integer and string arrays.
Suppose you have the following array: [135, 521, 523, 621, 683, 191]
What will it look like after the second iteration of radix sort?
[521, 523, 621, 135, 683, 191]
[521, 621, 523, 683, 135, 191]
[521, 191, 621, 523, 683, 135]
[521, 621, 523, 135, 683, 191]
O(1)
O(n long n)
O(n)
O(log n)
For which of the following classes of functions is binary search applicable?
Monotonic
Monotonically ascending only
Monotonically descending only
Convex functions
Find the median of the list [1, 4, 2, 6, 3, 7, 8].
(a)
What is the average-case time complexity of the QuickSelect algorithm?
O(n^2)
O(n)
O(n long n)
