Merge Sort
A divide-and-conquer algorithm that splits the array in half, sorts each half, and merges them back together.
Interactive Visualization
Loading visualization…
Usage
src/sample/mergesort.ts
import { mergeSort } from 'athro';
const arr = [2, 6, 3, 8];
const result = mergeSort(arr);
Time Complexity
| Case | Time Complexity | Description |
|---|---|---|
| Best | O(n log n) | Consistent divide-and-merge pattern |
| Average | O(n log n) | Stable performance across inputs |
| Worst | O(n log n) | Same recursive structure |