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

  1. Arrange the following functions of n in their correct order, using the idea of Order notation, giving the reasons:
    equation
  2. 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

  3. Here is a list of functions of one variable n:

     

    n5/100, 5, (log 2 n)2, n2/(1 + n), 22 log2n, n2 log 2 n, n2 + 27n, 2n

     

    Place them in a ...

Get Design and analysis of Algorithms, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.