Recall & Review
beginner
What does it mean for a sorting algorithm to be stable?
A stable sorting algorithm keeps the original order of equal elements the same after sorting. For example, if two items have the same value, they stay in the order they appeared before sorting.
Click to reveal answer
beginner
Name a common stable sorting algorithm.
Merge Sort is a common stable sorting algorithm. It keeps equal elements in their original order while sorting.
Click to reveal answer
intermediate
Why might you choose an unstable sort like Quick Sort over a stable sort?
Quick Sort is often faster and uses less memory than stable sorts. If you don't need to keep the order of equal elements, Quick Sort is a good choice for speed.
Click to reveal answer
intermediate
When is it important to use a stable sorting algorithm?
Use a stable sort when you want to sort by multiple criteria step-by-step. For example, first sort by age, then by name. Stability keeps the previous order intact.
Click to reveal answer
intermediate
What is a key difference between Merge Sort and Heap Sort regarding stability?
Merge Sort is stable, meaning it keeps equal elements in order. Heap Sort is unstable, so equal elements might change order after sorting.
Click to reveal answer
Which sorting algorithm is stable by default?
✗ Incorrect
Merge Sort keeps the order of equal elements, so it is stable. Quick Sort, Heap Sort, and Selection Sort are generally unstable.
Why choose a stable sort when sorting by multiple keys?
✗ Incorrect
Stable sorts keep the order of equal elements, which helps when sorting by multiple keys step-by-step.
Which sorting algorithm is usually fastest but unstable?
✗ Incorrect
Quick Sort is often the fastest in practice but is unstable.
If you want to sort a large list with limited memory and don't care about stability, which sort is best?
✗ Incorrect
Quick Sort uses less memory than Merge Sort and is fast, making it good for large lists when stability is not needed.
Which sorting algorithm is stable and good for linked lists?
✗ Incorrect
Merge Sort is stable and works well with linked lists because it doesn't require random access.
Explain what sorting stability means and why it matters when sorting by multiple criteria.
Think about how sorting twice by different keys keeps the order.
You got /3 concepts.
Describe when you would choose Quick Sort over Merge Sort and the trade-offs involved.
Consider performance and stability needs.
You got /4 concepts.