Looks like this question has been asked before, but I am not able to find an answer to it so I will ask again.

How do you compute the complexity of an algorithm in an average case? I can (barely) understand why Quicksort has O(n^2) in worst case, but I cannot figure out why it has O(nlogn) in an average case. Thanks so much.