Appendix D
Additional Exercises with Solutions
In this appendix we give additional exercise with their solutions.
D.1 Additional Exercises
D.1.1 Chapter 4: Loop Design Issues
- Arrange the following functions of n in their correct order, using the idea of Order notation, giving the reasons:
- Derive the asymptotic time complexity of the following algorithm:
Algorithm D.1 | print_n()
1 |
if n is non-zero then |
2 |
print the value (n/10) using print _n; |
3 |
print the digit (n mod 10); |
4 |
end |
- Here is a list of functions of one variable n:
n^{5}/100, 5, (log _{2} n)^{2}, n^{2}/(1 + n), 2^{2 log2n}, n^{2} log _{2} n, n^{2} + 27n, 2^{n}
Place them in a ...