3. Algorithms
Sorting Algorithms — Quiz
Test your understanding of sorting algorithms with 5 practice questions.
Practice Questions
Question 1
Using the Master theorem on the recurrence $T(n)=2T(n/2)+n$, what is the asymptotic time complexity of merge sort?
Question 2
In the worst case, quick sort on an $n$-element array satisfies the recurrence $T(n)=T(n-1)+n$. What is the asymptotic time complexity of this worst case?
Question 3
When insertion sort is applied to a reverse-sorted array of length $n$, how many element shifts occur in terms of $n$?
Question 4
Which modification makes the basic selection sort algorithm stable without changing its $O(n^2)$ worst-case time complexity?
Question 5
For an optimized bubble sort that exits early when no swaps occur, on a sorted array of length $n$, what are the numbers of comparisons and swaps performed?
