Several things I learnt in this read - First of all, I think I finally grok why quicksort average case is nlogn. The intuitive understanding using randomized version is simply to grasp. The tougher part is the actual O derivation. In both cases, it's not impossible to understand: CLRS's version is actually purely probabilistic so it is easier to understand, Sedgewick's version (7.2 of AIC) directly solve recursion. I think it is cleaner. Both require some understanding of harmonic sequence. Oh well, who doesn't have it?
Another thing I grokked is how the algorithm of i-th order statistics works. Arg, how difficult can that be? If the pivot index equals to i, you get the answer already. My question here is how to use red-black tree to come up with an answer like this as well.
A more challenging part is probably how to really write these algorithms. Now it's not a good time yet, but once I start the 2nd browse read. I will do something.
No comments:
Post a Comment