|
|
Take quiz & check grades |
Build Heaprunning time:
example:
Notice that, as you increase one level (double N), the new running time will be doubled (since there will be two subtrees) plus O(h) where h is the new height.
Book formula:Summation for h=0 to floor(lg n) ceiling ( n / ( 2 h+1 )) O(h) ... = n * Sum ( h / 2 h ) formula 3.6 in the book -> O ( n Sum ( h / 2 h)) form h=0 to infinity ---> O (n)
|