0

Let $t(n):=\begin{cases} \frac{2+\text{log}n}{1+\text{log}n}t(\lfloor\frac{n}{2}\rfloor) + log ((n!)^{\text{log} n}) \hspace{1cm} \text{if}\hspace{0.5cm} n>1 \\ 1 \hspace{0.5cm} \text{if}\hspace{0.2cm} n=1 \end{cases}$

We need to prove that $t(n) \in O(n²)$, thus $t(n) \leq c*n²$

I tried to play around with the master theorem (since $a,b > 1$)

so $a=\frac{2+\text{log} n}{1+ \text{log} n}$, $b=2$, $f(n)=\text{log}((n!)^{\text{log} n})=\text{log}n(\text{log}(n!))$

I have difficulties with the asymptotics of the $f(n)$ due to all the logarithms, help would be much appreciated.

  • It might be helpful to remember that $\log (n!) = \Theta (n\log n)$ (see https://math.stackexchange.com/questions/543634/what-is-the-order-of-the-sum-of-log-x for proofs of this). – Minus One-Twelfth May 24 '20 at 11:22
  • @Minus One-Twelfth thank you! so I could say that $log(n)log(n!) = \Theta(log(n) n log(n))$? – Inocenciaa May 24 '20 at 11:29
  • Yes, which can also be written as $\Theta (n (\log n)^{2})$. – Minus One-Twelfth May 24 '20 at 11:32
  • I need more or less show that $logn(log(n!)) = \Theta (n²)$, then it would follow that t(n) is also $\Theta(n²)$, since $a<b²$, so $\Theta((log n)²n) = \Theta(2log(n)n)$=$\Theta(log (n) n)$ initially we wanted to show that $f(n) \in \Theta(n²)$, so that of course holds, since $f(n) \in \Theta(log (n) * n)$ so we are kinda finished? – Inocenciaa May 24 '20 at 11:57

1 Answers1

1

Hint: \begin{align} \log(n!) &= \log(1 \cdot 2 \cdots (n-1) \cdot n) \\ &= \log(1) + \log(2) + \ldots + \log(n-1) + \log(n) \\ &\le \int_1^{n+1} \log(x) ~ dx\\ &= C\left. (x \log x - x) \right|_1^{n+1}\\ &= C\left(\left[ (n+1) \log (n+1) - (n+1)\right]- \left[ 1 \log (1) - 1\right] \right)\\ &= C\left(\left[ (n+1) \log (n+1) - n-1)\right]+1\right) \\ &= C\left( (n+1) \log (n+1) - n\right)\\ &\le C \left[ (n+1) \log (n+1) \right] \end{align}

John Hughes
  • 93,729
  • Thank you, what exactly is C? a constant I assume? why exactly can I write the integral as an upper bound? – Inocenciaa May 24 '20 at 11:33
  • $C$ is indeed a constant, because you're using $\log$ (wchih I assume is $\log_2$) rather than $\ln$. As for the integral: it measures the area of the region under the graph of $y = \log x$ between $1$ and $n+1$. Draw that region, and inscribe in it many width-one boxes: at the left end, a box of height $\log(1) = 0$; next to it, a box of height $\log(2)$, and so on. The last inscribed box has width $1$ and height $\log(n)$. – John Hughes May 24 '20 at 12:06
  • Thank you for your explanation – Inocenciaa May 26 '20 at 01:46