0
0
DSA C++programming~5 mins

Sorting Stability and When to Use Which Sort in DSA C++ - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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.
Click to reveal answer
beginner
Name a common stable sorting algorithm.
Merge Sort is a common stable sorting algorithm.
Click to reveal answer
intermediate
Why might you choose a stable sort over an unstable sort?
You choose a stable sort when you want to keep the relative order of equal elements, for example, when sorting by multiple keys step-by-step.
Click to reveal answer
intermediate
Which sorting algorithm is generally fastest for small arrays and why?
Insertion Sort is generally fastest for small arrays because it has low overhead and works well when the array is nearly sorted.
Click to reveal answer
intermediate
When should you prefer Quick Sort over Merge Sort?
Prefer Quick Sort when you want an in-place sort with good average performance and less memory use, but be aware it is not stable.
Click to reveal answer
Which of these sorting algorithms is stable?
AMerge Sort
BQuick Sort
CHeap Sort
DSelection Sort
Why is Insertion Sort preferred for small or nearly sorted arrays?
AIt uses extra memory
BIt has low overhead and adapts well to nearly sorted data
CIt is unstable
DIt always runs in O(n log n)
Which sorting algorithm is NOT stable?
ABubble Sort
BMerge Sort
CQuick Sort
DInsertion Sort
When sorting large data that does not fit in memory, which algorithm is preferred?
AQuick Sort
BInsertion Sort
CSelection Sort
DMerge Sort
Which sorting algorithm uses divide and conquer and is stable?
AMerge Sort
BHeap Sort
CQuick Sort
DSelection Sort
Explain what sorting stability means and give an example of when it matters.
Think about sorting a list of people first by age, then by name.
You got /3 concepts.
    Describe when you would choose Quick Sort, Merge Sort, or Insertion Sort.
    Consider memory use, stability, and data size.
    You got /3 concepts.