QUIZ 1

(In class, Sep 29, 1998)

QUESTIONS

  1. In Java, all classes are ultimately derived from one single class. Name this class.
  2. Two programs A and B have running times
    TA(n))=100 n log n + 10000
    TB(n))= n2 - 100
    (a) Which is the faster algorithm?
    (b) Qualify your answer to (a).
  3. Order the following functions according to their Theta-order (from smallest to largest):
    • (a) sqrt(n),
    • (b) log n,
    • (c) n log n,
    • (d) nlog23

ANSWERS

  1. The class is called the Object Class.
  2. (a) A is faster since O(n log n) is a asymptotically faster than O(n2).
    (b) But for small values of n, B may be faster. In the example above, for instance, it is easy to see that if n<100, then B is actually faster.
  3. ORDER: log n, sqrt(n), n log n, nlog23