Consider the following recursion tree for quick sort, which constantly divides subproblems into a 3-to-1 ratio (source: Khan Academy).
I understand that the partition subroutine in quicksort iterates through each subproblem and thus is O(n)
. However, I'm confused about why the "Total partitioning time for all subproblems" is cn
, and not just n
. What does the constant represent in this case? When/why would it be anything but 1? Is c
something you can solve for, or more a "conceptual" variable?
If I understand correctly, the partition subroutine visits each element in the given subproblem exactly once. And since the sum size of all subproblems at each level is n
, doesn't that mean exactly n
work is done at each level (at least before the log n / log4
boundary)?
Thanks