AlexandruValeanu / Introsort

Efficient implementation of the introsort sorting method in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Codacy Badge

Simple implementation of introsort (introspective sort) algorithm, hybrid of quicksort, heapsort, and insertion sort that has particularly good runtime behavior. It is one of the fastest comparison sorting, algorithms in use today, and is the usual implementation of the std::sort algorithm provided with the C++ STL.

Key attributes of this implementation:

  • 3-way partition
  • median of three (using 3 randomly chosen elements) for pivot selection
  • sorting networks for 1 ≤ N ≤ 6
  • insertion sort for 7 ≤ N ≤ 25
  • quicksort uses only one recursive call (the other one is transformed into tail recursion)
  • std::heap_sort if quicksort degenerates (depth > 2 * log(n))

About

Efficient implementation of the introsort sorting method in C++

License:MIT License


Languages

Language:C++ 88.1%Language:Python 10.7%Language:CMake 1.2%