6

I am having some problem trying to understand why

T(n)=16T(n/4)+n!

is considered

Θ(n!)

I am using the following master theorem below from here:

https://www.geeksforgeeks.org/advanced-master-theorem-for-divide-and-conquer-recurrences/

enter image description here

The confusing part here is that my friend says that the answer is actually O(n!) and not Θ(n!)... So I am really confused.

Belphegor
  • 1,683
  • 4
  • 23
  • 44
  • It should be `Thetha(n!)` if I am not wrong! Try using the theorem 4.1 stated in page 94 of [CLRS](https://mcdtu.files.wordpress.com/2017/03/introduction-to-algorithms-3rd-edition-sep-2010.pdf) – kiner_shah Dec 23 '18 at 06:05
  • @kiner_shah Is there a difference between the two master theorems? – Belphegor Dec 23 '18 at 06:09
  • 1
    They look different, although I am not sure if they really are the same and just have different representations – kiner_shah Dec 23 '18 at 06:11

1 Answers1

3

Theorem from CLRS:

Master theorem

In your case, a = 16, b = 4, f(n) = n!

Let's calculate nlogba. That will be n^2

Now, n! is definitely greater than n^(2-e) and n^2, so we will use third case of the theorem.

Let c = 0.5. This gives on substitution, 16 * (n / 4)! <= 0.5 * n!

Let's put a value in n and check:

If n = 100, 16 * (100 / 4)! <= 0.5 * 100! which gives 16 * 25! <= 0.5 * 100!. This inequality is correct since 100! will be way larger than 25!. Even multiplying with 16 won't make it greater than 0.5 * 100!.

This will be true for other larger values of n. So the complexity according to theorem should be bigtheta(n!)

kiner_shah
  • 3,939
  • 7
  • 23
  • 37