Merge Sort Visualizer — Animated, Step-by-Step
Animated merge sort with step controls, speed, custom input, live comparison/write counters and pseudocode. Runs in your browser.
Code examples
Ready-to-copy reference implementations. Free to use in your own projects and assignments.
How to use
- 1 Press Play to watch the array split into halves and merge back in sorted order.
- 2 Use Step to advance one merge comparison at a time.
- 3 Type your own numbers into Custom input and press Apply.
- 4 Follow the highlighted pseudocode and the live comparison / write counters.
Why use this tool
- See divide-and-conquer in action: recursive splits, then ordered merges.
- Understand why merge sort guarantees O(n log n) on every input.
- Metrics show the steady comparison count regardless of initial order.
- Runs entirely in your browser. No signup, no uploads.
Frequently asked questions
What is merge sort?
Merge sort recursively splits the array in half until each piece has one element, then merges the pieces back together in sorted order.
What is the time complexity of merge sort?
O(n log n) in the best, average, and worst case. The log n comes from the halving depth and the n from merging each level.
Is merge sort stable?
Yes — when merging, equal elements take the one from the left half first, preserving original order.
What is the downside of merge sort?
It needs O(n) extra memory for the merge buffers, unlike in-place sorts such as heap sort or quicksort.
What is Merge Sort Visualizer?
A Merge Sort Visualizer animates the divide-and-conquer process of merge sort: recursively splitting the array into halves and merging them back in sorted order. It demonstrates the guaranteed O(n log n) running time and stable ordering.
Features
Step-by-step animation
Watch the recursive split and the merge of sorted halves.
Complexity
Time: O(n log n) in all cases. Space: O(n) auxiliary. Stable; not in-place.
100% private
Runs entirely in your browser — nothing is uploaded.
Example
Input
[38, 27, 43, 3]
Output
split → [27,38] & [3,43]; merge → [3, 27, 38, 43] (sorted)
Common use cases
-
1
Guaranteed O(n log n)
See why merge sort avoids quicksort's O(n²) worst case.
-
2
Stable sorting
Observe that equal keys preserve their input order.
-
3
External / linked-list sort
Understand why merge sort suits linked lists and external sorting.
Zerethon's merge sort visualizer animates the divide-and-conquer algorithm in your browser, recursively splitting the array and merging sorted halves. Merge sort runs in O(n log n) time in the best, average, and worst case, using O(n) auxiliary space; it is stable but not in-place. Its guaranteed O(n log n) makes it a reliable choice for large data and linked lists.
- Category
- Algorithm
- Pricing
- Free
- Privacy
- Browser-based
- Signup
- Not required
References
- MIT OCW 6.006 — Introduction to Algorithms (CLRS) — MIT OpenCourseWare
- VisuAlgo — Sorting — VisuAlgo (NUS)
- Merge sort — Wikipedia
Privacy
Your data never leaves your browser unless explicitly stated. Merge Sort Visualizer runs entirely client-side — no server upload, no logging, no tracking of your input.
New to this? Read the step-by-step explanation with Big-O analysis: Learn Sorting Algorithms →
Compare
Related tools
Bubble Sort Visualizer
Animated bubble sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs entirely in your browser.
Open toolInsertion Sort Visualizer
Animated insertion sort with step controls, speed, custom input, live comparison/write counters and pseudocode. Runs in your browser.
Open toolSelection Sort Visualizer
Animated selection sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs in your browser.
Open toolQuick Sort Visualizer
Animated quicksort with pivot/partition highlights, step controls, speed, custom input, live counters and pseudocode. Runs in your browser.
Open toolBuild, share, and grow on Zerethon Social
Free signup. Earn points, collect achievements, and connect with creators worldwide.