Preorder Example in Java


public static void printdir (Object dir, int level) {
    for ( int i = 0; i < level; i++ )
        System.out.print("  ");
    if ( ! consp(dir) )
        System.out.println(dir);
    else {  System.out.println(first((Cons) dir));
            while ( rest((Cons) dir) != null ) {
                dir = rest((Cons) dir);
                printdir(first((Cons) dir),
                         level + 1); } } }                


(/usr (mark (book ch1.r ch2.r ch3.r)
            (course (cop3530 (fall05 syl.r)
                      (spr06 syl.r) (sum06 syl.r)))
            (junk))
      (alex (junk)) 
      (bill (work) ... ))


/usr
  mark
    book
      ch1.r
      ch2.r
      ch3.r
    course   ...

Contents    Page-10    Prev    Next    Page+10    Index