RK DSA Studio

Merge sort

Recursively sort halves, then merge their sorted values using an auxiliary buffer.

Remember: Split → sort halves → merge.

Example: [4,1,3,2] → [1,4] + [2,3] → [1,2,3,4].

Time: O(n log n). Auxiliary space: O(n).

Formula: T(n) = T(⌊n/2⌋) + T(⌈n/2⌉) + O(n)

Up to 15 integers. Stable: equal values are taken from the left half first. Auxiliary buffers and recursive stack together use O(n) space.

Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.

The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.