Function to perform introsort on the given array
| 80 | |
| 81 | // Function to perform introsort on the given array |
| 82 | void introsort(int a[], int *begin, int *end, int maxdepth) |
| 83 | { |
| 84 | // perform insertion sort if partition size is 16 or smaller |
| 85 | if ((end - begin) < 16) { |
| 86 | insertionsort(a, begin - a, end - a); |
| 87 | } |
| 88 | // perform heapsort if the maximum depth is 0 |
| 89 | else if (maxdepth == 0) { |
| 90 | heapsort(begin, end + 1); |
| 91 | } |
| 92 | else { |
| 93 | // otherwise, perform Quicksort |
| 94 | int pivot = randPartition(a, begin - a, end - a); |
| 95 | introsort(a, begin, a + pivot - 1, maxdepth - 1); |
| 96 | introsort(a, a + pivot + 1, end, maxdepth - 1); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | int main() |
| 101 | { |
no test coverage detected