quickSort<T extends Comparable> function
🧠Quick Sort Algorithm (Generic Version)
Sorts a list using the quick sort algorithm. This implementation uses recursion and a partition function. Time Complexity:
- Average: O(n log n)
- Worst: O(n^2)
Requires:
Tmust extend Comparable
Implementation
void quickSort<T extends Comparable>(List<T> list, int low, int high) {
if (low < high) {
int pi = _partition(list, low, high);
// Recursively sort left and right sublists
quickSort<T>(list, low, pi - 1);
quickSort<T>(list, pi + 1, high);
}
}