βοΈ Check List (Check all the applicable boxes)
[x] My code follows the code style of this project.
[x] This PR does not contain plagiarized content.
[x] The title of my pull request is a short description of the requested changes.
π Note to reviewers
Intro sort is a hybrid sorting algorithm that combines quicksort, heapsort, and insertion sort to achieve efficient sorting performance. Here's a brief overview of how it works:
The algorithm starts with quicksort, which selects a pivot element and partitions the array into two sub-arrays.
If the recursion depth exceeds a predetermined threshold, indicating the potential for worst-case behavior, the algorithm switches to an alternative sorting algorithm (typically heapsort).
The alternative sorting algorithm is used to sort the remaining unsorted sub-arrays. Heapsort has a guaranteed worst-case time complexity of O(n log n).
For small sub-arrays, the algorithm may further switch to insertion sort, which is efficient for such cases.
By dynamically adapting between quicksort, heapsort, and insertion sort based on the input data and recursion depth, intro sort achieves a balance between quicksort's average-case performance and the worst-case performance guarantees of alternative sorting algorithms. This makes it a highly efficient sorting algorithm for a wide range of input scenarios.
π οΈ Issue (Number)
Issue no #1226
π¨βπ» Changes proposed
βοΈ Check List (Check all the applicable boxes)
π Note to reviewers
Intro sort is a hybrid sorting algorithm that combines quicksort, heapsort, and insertion sort to achieve efficient sorting performance. Here's a brief overview of how it works:
The algorithm starts with quicksort, which selects a pivot element and partitions the array into two sub-arrays.
If the recursion depth exceeds a predetermined threshold, indicating the potential for worst-case behavior, the algorithm switches to an alternative sorting algorithm (typically heapsort).
The alternative sorting algorithm is used to sort the remaining unsorted sub-arrays. Heapsort has a guaranteed worst-case time complexity of O(n log n).
For small sub-arrays, the algorithm may further switch to insertion sort, which is efficient for such cases.
By dynamically adapting between quicksort, heapsort, and insertion sort based on the input data and recursion depth, intro sort achieves a balance between quicksort's average-case performance and the worst-case performance guarantees of alternative sorting algorithms. This makes it a highly efficient sorting algorithm for a wide range of input scenarios.
π· Screenshots
intro_sort.cpp
intro_sort.py
intro_sort.java