Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

Exercises

  1.   Determine the running times predicted by the detailed model of the computer given in Section gif for each of the following program fragments:
    1. for (int i = 0; i < n; ++i)
          ++k;
    2. for (int i = 1; i < n; i *= 2)
          ++k;
    3. for (int i = n - 1; i != 0; i /= 2)
          ++k;
    4. for (int i = 0; i < n; ++i)
          if (i % 2 == 0)
              ++k;
    5. for (int i = 0; i < n; ++i)
          for (int j = 0; j < n; ++j)
              ++k;
    6. for (int i = 0; i < n; ++i)
          for (int j = i; j < n; ++j)
              ++k;
    7. for (int i = 0; i < n; ++i)
          for (int j = 0; j < i * i; ++j)
              ++k;
  2. Repeat Exercise gif, this time using the simplified model of the computer given in Section gif.
  3. Prove by induction the following summation formulas:
    1. tex2html_wrap_inline57880
    2. tex2html_wrap_inline57882
    3. tex2html_wrap_inline57884
  4. Evaluate each of the following series summations:
    1. tex2html_wrap_inline57886
    2. tex2html_wrap_inline57888
    3. tex2html_wrap_inline57890
    4. tex2html_wrap_inline57892
  5. Show that tex2html_wrap_inline57894, for tex2html_wrap_inline57896. Hint: Let tex2html_wrap_inline57898 and show that tex2html_wrap_inline57900.
  6. Show that tex2html_wrap_inline57902. Hint: Let tex2html_wrap_inline57904 and show that the difference tex2html_wrap_inline57906 is (approximately) a geometric series summation.
  7. Solve each of the following recurrences by repeated substitution:
    1. tex2html_wrap_inline57908
    2. tex2html_wrap_inline57910
    3. tex2html_wrap_inline57912
    4. tex2html_wrap_inline57914
    5. tex2html_wrap_inline57916
    6. tex2html_wrap_inline57918
    7. tex2html_wrap_inline57920

next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.