Published on

The Algorithm Design Manual (3rd) Exercise Solution 'E2-24'

Table of Contents

Introduction

This series is my solutions for algorithm exercises in'The Algorithm Design Manual' 3rd edition.
It's my solutions, not model answers, so if you find some mistakes or more sophisticated solutions, please post in comment area below.

Repository

Here

Exercise 2-24

Question

List the functions below from the lowest to the highest order. If any two or more are of the same order, indicate which.

nππn(n5)2n(nn4)2log4nn5(logn)2n4(nn4)\begin{matrix} n^\pi &\pi^n &\binom{n}{5} &\sqrt{2^{\sqrt{n}}}\\ \binom{n}{n-4} &2^{\log^4n} &n^{5(\log{n})^2} &n^4\binom{n}{n-4} \end{matrix}

Solution

[1] First, the order of the sequence whose components' order is dominated by a power of a read number is simply the same as the order of their exponent.
And, an expansion of binomial statement produces polynomial.

Think of expanding binomals:

(n5)=15!n(n1)(n2)(n3)(n4)=Θ(n5)(nn4)=n!(n4)!4!=Θ(n4)n4(nn4)=n4Θ(n4)=Θ(n8)\begin{align} \binom{n}{5}&=\frac{1}{5!}n(n-1)(n-2)(n-3)(n-4)\\ &=\Theta(n^5)\\\\ \binom{n}{n-4}&=\frac{n!}{(n-4)!4!}\\ &=\Theta(n^4)\\\\ n^4\binom{n}{n-4}&=n^4*\Theta(n^4)\\ &=\Theta(n^8) \end{align}

So, the order of them, plus nπn^\pi (3<π<43 \lt \pi \lt 4), is:

nπ<(nn4)<(n5)<n4(nn4)\begin{equation} n^\pi \lt \binom{n}{n-4} \lt \binom{n}{5} \lt n^4\binom{n}{n-4} \end{equation}

[2] Make the 4th statement easy:

2n=(2n12)12=2n122\begin{align} \sqrt{2^{\sqrt{n}}}&=(2^{n^\frac{1}{2}})^{\frac{1}{2}}\\ &=2^{\frac{n^{\frac{1}{2}}}{2}} \end{align}

So the form belongs to more generic form:

2n{x:x=2anb(a,bR)}\begin{equation} \sqrt{2^{\sqrt{n}}}\in\{x:x=2^{an^b} (a,b\in\mathbb{R})\} \end{equation}

[3] Think of 2log4n2^{\log^4n} and its range.

Is n^b dominate log^4n?

limnlog4nnb=limx((logn)1nb4)4=limn((log(n4b)14b)1nb4)4=limn1(4b)4log(nb)1nb\begin{align} \lim\limits_{n \to \infty}{\frac{\log^4n}{n^b}}&=\lim\limits_{x \to \infty}((\log{n})*\frac{1}{n^{\frac{b}{4}}})^4\\ &=\lim\limits_{n \to \infty}((\log{(n^{4b})^{\frac{1}{4b}}})*\frac{1}{n^{\frac{b}{4}}})^4\\ &=\lim\limits_{n \to \infty}\frac{1}{(4b)^4}\log{(n^b)^\frac{1}{n^b}} \end{align}

Here we use following well known relationship:

limmm1m=1\begin{equation} \lim\limits_{m \to \infty}m^{\frac{1}{m}}=1 \end{equation}

And limnlog4nnb\lim\limits_{n \to \infty}{\frac{\log^4n}{n^b}} converges:

limnlog4nnb=limn1(4b)4log1=0\begin{align} \lim\limits_{n \to \infty}{\frac{\log^4n}{n^b}}&=\lim\limits_{n \to \infty}\frac{1}{(4b)^4}\log{1}\\ &=0 \end{align}

Therefore, nbn^b dominate log4n\log^4n.

Meanwhile, for sufficiently large n, log4n\log^4n dominates logn\log{n}.

So, for sufficiently large n, the following relations hold:

a1logn<log4n<a2nb    na1<2log4n<2a2nb(a1,a2,bR)\begin{align} &a_1\log{n}\lt\log^4n\lt a_2n^b\\ \iff &n^{a_1}\lt 2^{\log^4n} \lt 2^{a_2n^b} \quad(a_1,a_2,b\in\mathbb{R}) \end{align}

Comparing the result of [2], we get the following:

2log4n<2n\begin{equation} 2^{\log^4n} \lt \sqrt{2^{\sqrt{n}}} \end{equation}

[4] Think of n5(logn)2n^{5(\log{n})^2} and its range.

First, set the value as m and take the log of n for both sides.

m=n5(logn)2    lognm=5(logn)2\begin{align} &m=n^{5(\log{n})^2}\\ \iff &\log_n{m}=5(\log{n})^2 \end{align}

LHS can be rearranged:

lognm=1lognlg10lgm\begin{equation} \log_n{m}=\frac{1}{\log{n}*\lg10}\lg{m} \end{equation}

So, combine the results above:

lgm=5lg10(logn)3    m=25lg10(logn)3\begin{align} &\lg{m}=5\lg10(\log{n})^3\\ \iff& m=2^{5\lg10(\log{n})^3} \end{align}

(logn)4(\log{n})^4 dominates (logn)3(\log{n})^3, and (logn)3(\log{n})^3 dominates logn\log{n}.
So, n5(logn)2n^{5(\log{n})^2} can be integrated in [3]'s result:

na<n5(logn)2<2log4n<2n(aR)\begin{equation} n^{a}\lt n^{5(\log{n})^2} \lt 2^{\log^4n} \lt \sqrt{2^{\sqrt{n}}} \quad(a\in\mathbb{R}) \end{equation}

[5] For sufficiently large nn, πn\pi^n is larger than 3n3^n, and 3n3^n is larger than 2n2^n.
so,

2n<πn\begin{equation} \sqrt{2^{\sqrt{n}}} \lt \pi^n \end{equation}

Using [1] to [5], the order we want is:

nπ<(nn4)<(n5)<n4(nn4)<n5(logn)2<2log4n<2n<πn(the answer)\begin{align} &n^\pi \lt \binom{n}{n-4} \lt \binom{n}{5} \lt n^4\binom{n}{n-4} \\ \lt &n^{5(\log{n})^2} \lt 2^{\log^4n} \lt \sqrt{2^{\sqrt{n}}} \lt \pi^n \quad(\text{the answer}) \end{align}