Merge sort
How it works
Merge Sort divides the list into smaller parts, sorts them, and then merges them back together. It's a powerful "divide and conquer" strategy!
-
🔹 How it works: Split into halves → Sort each half → Merge them back in order.
-
🔹 Best & worst case: Always runs in O(n log n) (much faster than O(n²)!).
-
🔹 Why learn it? It's one of the most efficient sorting algorithms for large datasets.
👀 Think of it as: Splitting a puzzle into smaller pieces, solving them, then putting it back together.
How it works in code
How to play
Goal: Merge sorted halves by picking the smallest element from either side.
Buttons:
-
Left ⬅️ → Selects the smallest element from the left group.
-
Right ➡️ → Selects the smallest element from the right group.
-
Submit ✅ → Checks if all elements were merged correctly.
👀 Tip: Always pick the smallest available element when merging!
Time:
0:60
Lives:
❤️❤️❤️