CSE 326, Spring 1998: Homework 3

Due 4/17/98

When asked to design an algorithm please provide the pseudocode with enough explanation that it can be understood easily.

  1. (15 points) Consider the following general recurrence T(1) <= d and T(n) <= aT(n/b) + cn for a time bound. Show that: You may assume that n is a power of b in your argument. A very good argument would determine the constants and low order terms hidden in the big O notation, and show the bound by induction on n.
  2. (15 points) It is often handy to store a tree in a file. Assume each node in the tree contains an alphabetic character. In this case we may store a tree by inserting parentheses appropriately while doing a preorder traversal. The general idea is that a node is followed by the list of its children surrounded by parentheses. For example:
                               
                                  a
                                / | \
                               b  c  d
                              /    / | \
                             e    f  g  h
    
    is stored as the file "a ( b ( e ) c d ( f g h ) )" where spaces indicate newlines. We call this the preorder file format.