Comparing worst case Counting Sort with quickSort algorithm

599 Views Asked by At

I have a question which I am trying to solve for personal understanding of comparing algorithms as follows. I am given $n$ to be the number of objects and $m$ be the number of keys. I want to find the ratios objects/keys that CountingSort is faster in the worst case compared to QuickSort when quicksort chooses the last element as the pivot. So I have that the worst case running time for CountingSort is $O(n+k)$ and the case when quicksort chooses the last element as the pivot is $\Theta(n^2)$. I'm confused of how to approach this question and would welcome some guidance so I could reach a solution. Thank you.

[EDIT] My idea is that it will be for when the number of keys is double the number of objects? So we have that the runtime for worst case of quicksort is $O(n^2)$ so we want to have counting sort less than this. Therefore if we have rations of m/n < $m^2$/n this will be the case?