How to calculate order (big O) for more complex algorithms (ie quicksort)

Posted by bangoker on Stack Overflow See other posts from Stack Overflow or by bangoker
Published on 2010-04-12T23:37:12Z Indexed on 2010/04/12 23:42 UTC
Read the original article Hit count: 301

Filed under:
|
|

I know there are quite a bunch of questions about big O notation, I have already checked Plain english explanation of Big O , Big O, how do you calculate/approximate it?, and Big O Notation Homework--Code Fragment Algorithm Analysis?, to name a few.

I know by "intuition" how to calculate it for n, n^2, n! and so, however I am completely lost on how to calculate it for algorithms that are log n , n log n, n log log n and so.

What I mean is, I know that Quick Sort is n log n (on average).. but, why? Same thing for merge/comb, etc.

Could anybody explain me in a not to math-y way how do you calculate this?

The main reason is that Im about to have a big interview and I'm pretty sure they'll ask for this kind of stuff. I have researched for a few days now, and everybody seem to have either an explanation of why bubble sort is n^2 or the (for me) unreadable explanation a la wikipedia

Thanks!

© Stack Overflow or respective owner

Related posts about big-o

Related posts about algorithm