Sahaj.blogs

Day page

23 Jan 2024

Study

C++ · DSA: sorting

Insertion sort and merge sort written by hand, compared with std::sort and std::stable_sort on the same data.

  • Insertion sort is O(n²) but fast on small or nearly sorted inputs; merge sort is O(n log n) and stable.
  • std::stable_sort keeps equal elements in their original order; std::sort does not promise that.

Read the post →