Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Merge Sort
Recursive (Top-Down)
Iterative (Bottom-Up)
1
mergeSort([...])
Standard
Small
Reverse Sorted
Already Sorted
Nearly Sorted
All Equal
Custom
arr
=
[38, 27, 43, 3, 9, 82, 10]
0
1
2
3
4
5
6
38
27
43
3
9
82
10
0
1
2
3
4
5
6
38
27
43
3
9
82
10
depth =
3
0
1
2
3
4
5
6
38
27
43
3
9
82
10
recurse right → sort(arr,
1
,
1
)
depth =
3
0
1
2
3
4
5
6
38
27
43
3
9
82
10
split arr[
2
..
3
] at mid =
2
depth =
3
0
1
2
3
4
5
6
temp
i
38
27
3
9
82
10
43
right run empty → copy
43
across
depth =
2
0
1
2
3
4
5
6
temp
i
j
27
43
3
9
82
10
38
38
≤
43
→ take
38
from the left run
depth =
4
0
1
2
3
4
5
6
38
27
43
3
9
82
10
arr[
4
] is a single element →
already sorted
depth =
2
0
1
2
3
4
5
6
38
27
43
3
9
82
10
recurse right → sort(arr,
6
,
6
)
depth =
2
0
1
2
3
4
5
6
temp
38
27
43
3
9
82
10
arr[
4
..
6
] is now a
sorted run
depth =
1
0
1
2
3
4
5
6
temp
i
j
38
27
43
3
9
82
10
27
≤
82
?
0
1
2
3
4
5
6
38
27
43
3
9
82
10
Array is sorted
Step:
Start: sort the array with recursive (top-down) merge sort
0 / 72
Standard
Small
Reverse Sorted
Already Sorted
Nearly Sorted
All Equal
Custom
arr
=
[38, 27, 43, 3, 9, 82, 10]
0 / 72
Step:
Start: sort the array with recursive (top-down) merge sort
1
mergeSort([...])