0

I have figured out how to get 2n/3 from the following question:

Worst case in Max-Heapify - How do you get 2n/3?

"In CLRS, third Edition, on page 155, it is given that in MAX-HEAPIFY:

'The children’s subtrees each have size at most 2n/3—the worst case occurs when the bottom level of the tree is exactly half full.'"

However, I wonder, when the bottom level of the tree is exactly half full, we get:

T(n) <= T(2n/3) + theta(1)

Then on the next recursive call on its subtree, the bottom level of this subtree is all full (since we have assumed in advance that this side is as full as possible while the other side is empty to get the above recurrence). Thus, the recurrence on the next call would be:

T(n) <= T(n/2) + theta(1)

and would be the same every recursive call thereafter.

The recurrence actually changes and how can we still use the master theorem?

But then I find that since a = 1, and f(n) = n^0, then whatever b is, the worst case running time would always be O(lgn), so why do we bother to figure out what b is?

Thanks

fatpanda2049
  • 483
  • 1
  • 4
  • 9

1 Answers1

0

The first time complexity is O(log_{1.5} n), but the second one is O(log_2(n)). Hence, the worst case is the worst!

OmG
  • 18,337
  • 10
  • 57
  • 90