Merge Sort
7 min read.
A classic Divide and Conquer algorithm. It divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves.
Think of it this way: Imagine sorting a deck of cards. It's hard to sort 52 cards at once. So you split the deck until you have piles of 1 card (which are sorted!). Then you merge pairs of piles back together in order. Divide and Conquer!
Start: split until each piece has one element, then merge sorted pieces.
Check your understanding
Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.
Divide, then conquer
Order the stages of merge sort.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
- 1Drop a step here
- 2Drop a step here
- 3Drop a step here
- 4Drop a step here
- 5Drop a step here
Quiz
20 questionsIs Merge Sort a stable sorting algorithm?
Done with this lesson?
Sign in free to keep your progress, streak and quiz scores.