logo
SEE ALGORITHMS
    Bubble Sort
    Insertion Sort
    Selection Sort
    Heap Sort
    Radix Sort
    Merge Sort
    Quick Sort

Merge Sort

Merge Sort is more advanced, divide-and-conquer algorithm that recursively splits an unsorted list into smaller sublists until each contains a single element. These sublists are then merged back together in a sorted manner. With a time complexity of O(n log n), Merge Sort is efficient and stable, making it suitable for handling large datasets.

Things to Observe

  • Divide Recursively: Watch how the algorithm first breaks the array down recursively into single-element sub-arrays.
  • Conquer (Merge): These sub-arrays are then merged back together in sorted order. This merging step is where the core sorting logic happens, comparing elements from the sub-arrays and placing them into a temporary array before updating the main one.

Pseudocode

function mergeSort(start, end):
    if start < end:
        mid = (start + end) / 2
        mergeSort(start, mid)
        mergeSort(mid + 1, end)
        merge(start, mid, end)
Select number of elements:  

Curious to Learn More?

Hand-picked resources to deepen your understanding

Beginner Friendly
Coding Interview Bootcamp: Algorithms + Data Structures

Learn essential data structures and algorithms step-by-step with practical JavaScript examples.

Practical Guide
JavaScript Algorithms & Data Structures Masterclass

Master DSA fundamentals, problem-solving techniques, and advanced structures using JavaScript.

Deep Dive
Master the Coding Interview: Data Structures + Algorithms

Prepare for top tech interviews with advanced DSA concepts and real-world coding challenges.

Learn DSA on Udemy
Learn DSA on Udemy
As an Udemy Associate, I earn from qualifying purchases.

© 2025 SEE Algorithms. Code licensed under MIT, content under CC BY-NC 4.0.