Back to All Algorithms
Merge Sort
Category: Sorting | Time: O(n log n) | Space: O(n)
Visualization
Visual representation of the data structure
Enter an algorithm and input to start visualization.
About Merge Sort

An efficient, stable, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the order of equal elements is the same in the input and output. Merge sort is a divide and conquer algorithm that was invented by John von Neumann in 1945. The algorithm splits the array into two halves, recursively sorts them, and then merges the two sorted halves.

Code Editor
The code is for reference. Editing it won't affect the visualization.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Frequently Asked Questions
About Merge Sort

Related Interview Questions
Practice with real problems