Skip to content

Efficient implementation of the introsort sorting method in C++

License

Notifications You must be signed in to change notification settings

AlexandruValeanu/Introsort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published