Share
Explore BrainMass

Worst Case for Quick Sort Algorithm and Improvement

Describe the worst case scenario for quick sort algorithm. Any ideas to improve the worst case? Comment on the improvement in running time vs. increase in code complexity.

Solution Preview

The worst case for Quicksort depends on the selection of the pivot element. Normally, if the first or the last element is chosen then there is a danger that the all the rest of the numbers need to be moved to the other side of the pivot and this happens recursively. In other words, the worst-case occurs when the input is already sorted. Since, many real-life inputs are nearly sorted, quicksort might perform worse ...

Solution Summary

Discusses the worst case condition for quick sort algorithm. Also suggests ideas to improve the worst case and comments on the improvement in running time vs. increase in code complexity.

$2.19