Algorithms and Data Structures · Senior · Question 32 of 75

What is introsort and why is it used in C++ std::sort?

Explanation

Quicksort is fast on average, but its O(n²) worst case can be triggered. Introsort limits recursion depth to about 2 log n and switches to heapsort, guaranteeing O(n log n) while keeping quicksort speed.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 32

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz