Table of Contents
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.
Here
List the functions below from the lowest to the highest order. If any two or more are of the same order, indicate which.
∑i=1niin!nn2log4n(logn)lognn(logn)22logn2(n−4n)[1] Think of \sum_1^n i^i.
The summertion's last term is nn and each tesm is smaller than in except the last term.
So the following inequation holds.
nn≤i=1∑nii≤i=1∑nin=i=1∑n−1in+nnThe RHS of the statement above is fhuther bounded as:
i=1∑n−1in+nn≤(n−1)∗nn−1+nn=2nn−nn−1=Θ(nn)Meanwhile, the order of n^n is apparently Θ(nn).
Therefore, the order we want to derive is:
i=1∑nii=Θ(nn)[2] Think of n! and its relations with other well-known ordering characters.
The terms in the factorial is less than n except the first term n.
So, the following inequation is derived:
n!=n∗(n−1)∗(n−2)⋯<n∗n∗n⋯=nnMeanwhile, the terms is greater than 2 except the last one (=1).
So,
n!>2∗2∗2⋯=2n−1=21∗2nThe relation of order regarding n! is following:
2n<n!<nn[3] Then, think of (logn)logn.
Compare it with the simple power of n.
(logn)lognna=(logn)logn2alogn=(logn2a)logn(a∈R)The base of the exponentation is smaller than 1 when n>102a.
So, for sufficiantly large n, the following inequation holds.
na<(logn)lognAnd, logn is smaller than n when n≥1.
So, for sufficiantly large n, the following inequation holds.
(logn)logn<nlogn<n(logn)2Using [1] to [5] and the result of exercise 2-24, the order we want is:
2logn2<(n−4n)<(logn)logn<n(logn)2<2log4n<n!<nn=i=1∑nii