views:

76

answers:

2

Lets say you have an array of size 1,000,000 with randomly generated elements and you want to use quicksort to sort the array. In order to speed up quicksort, it would make sense to stop recursing when the array gets small enough, and use insertion sort instead. In such an implementation, the base case for Quicksort is some value base > 1. What would the optimal base value to choose and why?

A: 

Think about the time complexity of quicksort (average and worst case) and the time complexity of other sort that might do better for small n.

Ken Struys
A: 

Try starting with Wikipedia - it has good starting info about comparing the two algorithms. When you have a more specific question, feel free to come back.

Carl