Question 8 of 12: Algorithm Analysis, Big-O, and Growth-Rate Ordering
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
National Examination, 04-BS-16 Discrete Mathematics, Dec 2013. Closed book, no aids, 3 hours, 12 questions of 10 marks each (100 marks); the exam instructs "answer 10 of 12" but every question is solved below as a complete study resource.
Reference texts: Rosen, Discrete Mathematics and Its Applications, 7th ed. (logic Ch.1, sets Ch.2, induction & pigeonhole Ch.5-6, relations Ch.9, counting Ch.6, discrete probability Ch.7, graphs Ch.10-11); Epp, Discrete Mathematics with Applications.
Question 8: Algorithm Analysis, Big-O, and Growth-Rate Ordering (10 marks)
Given. Loop: $y\leftarrow x$; while $y\ge2$: $y\leftarrow\sqrt y$ (one sqrt call per pass), $x\ge0$ real.
Find. (a) A closed-form iteration count. (b) The Big-O definition. (c) The correct growth-rate ordering.
(a) Model repeated square-rooting. After $k$ passes, $y=x^{1/2^k}$. The loop keeps executing while $y\ge2$, so the number of passes $n$ is the smallest integer with $x^{1/2^n}<2$:
$$x^{1/2^n}<2 \iff \frac{\log_2x}{2^n}<1 \iff \log_2x<2^n \iff n>\log_2(\log_2x).$$
Checking $x=16$: $\log_2(\log_2 16)=\log_2 4=2$, so $n=\lfloor2\rfloor+1=3$ — trace: $16\to4\to2\to1.41$ (stop), 3 sqrt calls ✓. So for $x\ge2$:
$$\boxed{n(x)=\lfloor\log_2(\log_2 x)\rfloor+1}\quad(\text{and }n(x)=0\text{ for }0\le x<2,\text{ loop never enters}).$$
(b) Definition of Big-O. $f(n)=O(g(n))$ means $\exists$ positive constants $c,n_0$ such that $\boxed{0\le f(n)\le c\,g(n)\ \text{for all}\ n\ge n_0}$ — $g$ is an asymptotic upper bound on $f$ up to a constant factor, beyond some threshold.
(c) Order the eight functions. Group by type: iterated-log $\prec$ log $\prec$ polylog $\prec$ polynomial (fractional then integer power) $\prec$ exponential $\prec$ factorial/super-exponential. Applying this hierarchy to the given list:
$$\boxed{\log\log n \;\prec\; \log n \;\prec\; (\log n)^2 \;\prec\; \sqrt n \;\prec\; n\log n \;\prec\; n^3 \;\prec\; 2^n \;\prec\; n^n.}$$
Final results — Question 8
Part
Result
(a)
$n(x)=\lfloor\log_2(\log_2x)\rfloor+1$ for $x\ge2$; $0$ for $x<2$