Question on computing the average time of Quicksort
- From: Chad <cdalten@xxxxxxxxx>
- Date: Mon, 28 Apr 2008 16:13:42 -0700 (PDT)
The question comes from the following wikipedia entry
http://en.wikipedia.org/wiki/Quicksort
"Average complexity
Even if pivots aren't chosen randomly, quicksort still requires only
Θ(nlogn) time over all possible permutations of its input. Because
this average is simply the sum of the times over all permutations of
the input divided by n factorial, it's equivalent to choosing a random
permutation of the input. When we do this, the pivot choices are
essentially random, leading to an algorithm with the same running time
as randomized quicksort.
More precisely, the average number of comparisons over all
permutations of the input sequence can be estimated accurately by
solving the recurrence relation:"
I don't see how they arrive at the recurrence relation. If there are
n-1 comparisons, I thought it would be
for i=0 to n-1
C(n) = 1/n * (sum(c(n - i - 1))
I don't get were the n-1 and C(i) terms come from.
Can someone clarify this?
Thank you.
.
- Prev by Date: Re: Programming to Beat the Odds in Gaming
- Next by Date: The computational complexity of the Sieve of Eratosthenes
- Previous by thread: Programming to Beat the Odds in Gaming
- Next by thread: The computational complexity of the Sieve of Eratosthenes
- Index(es):
Relevant Pages
|