0
0
DSA Goprogramming~5 mins

Sorting Stability and When to Use Which Sort in DSA Go - 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. 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?
AMerge Sort
BQuick Sort
CHeap Sort
DSelection Sort
Why choose a stable sort when sorting by multiple keys?
ATo keep the order of equal elements from previous sorts
BBecause stable sorts are always faster
CTo use less memory
DBecause unstable sorts can't sort multiple keys
Which sorting algorithm is usually fastest but unstable?
ABubble Sort
BQuick Sort
CInsertion Sort
DMerge Sort
If you want to sort a large list with limited memory and don't care about stability, which sort is best?
ACounting Sort
BMerge Sort
CBubble Sort
DQuick Sort
Which sorting algorithm is stable and good for linked lists?
AHeap Sort
BQuick Sort
CMerge Sort
DSelection Sort
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.