0
0
DSA Javascriptprogramming~5 mins

Sorting Stability and When to Use Which Sort in DSA Javascript - 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 an unstable sort like Quick Sort over a stable sort?
Quick Sort is often faster and uses less memory, so it is chosen when speed and space are more important than keeping equal elements in order.
Click to reveal answer
beginner
Which sorting algorithm is best for nearly sorted data and why?
Insertion Sort is best for nearly sorted data because it runs very fast when the list is almost sorted.
Click to reveal answer
intermediate
What is a key factor in deciding which sorting algorithm to use?
Key factors include data size, whether stability is needed, memory limits, and if the data is nearly sorted or random.
Click to reveal answer
Which sorting algorithm is stable by default?
AQuick Sort
BMerge Sort
CHeap Sort
DSelection Sort
When is Insertion Sort a good choice?
AFor very large random data
BWhen memory is very limited
CFor nearly sorted data
DWhen stability is not important
Why might Quick Sort be preferred over Merge Sort?
AIt uses less memory and is often faster
BIt is stable
CIt works better on nearly sorted data
DIt is easier to implement
What does an unstable sort do with equal elements?
AKeeps their original order
BSorts only unique elements
CRemoves duplicates
DMay change their original order
Which factor is NOT important when choosing a sorting algorithm?
AColor of the data
BNeed for stability
CData size
DMemory availability
Explain what sorting stability means and give an example of when you would need a stable sort.
Think about keeping order of equal items.
You got /3 concepts.
    Describe how you would choose a sorting algorithm based on data size, stability needs, and data order.
    Match algorithm strengths to data conditions.
    You got /4 concepts.