CS 302 - Data Structures & Algorithms - Spring 2008
Programming Assignment 2


Loyola College > Department of Computer Science > CS 302 > Programming Assigngments > Programming Assignment 2

Binary Tree Fun

Due

Design: Monday, February 11, 2008
Project:Wednesday, February 20, 2008 at the beginning of class

The Assignment

Using C under Linux implement a binary tree ADT. A binary tree has the operations:
  1. insert(x): add item x to the collection stored in the tree (duplicates ok),
  2. search(x): determines if x is contained in the tree (and if so return it's item), and
  3. delete(x): removes one instance of item x from the collection stored in the tree.
    Functions insert(x) and delete(x) return the updated tree.
For Assignment 2, also include
  1. DFS(x): find the first occurrence of x in depth-first order.
  2. BFS(x): find the first occurrence of x in breadth first order.
  3. DFD: depth first dump: dump the tree in depth-first order.
  4. BFD: breadth first dump: dump the tree in breadth-first order.

What to hand in

  1. Design: A one to two page program design (hand written ok). Be sure to cover all the delete cases! (unless otherwise stated all work handed in should be typed.)
    Hand this back in with your source code.
  2. A well formated 2-up listing of your code. (see a2ps(1))
  3. Email a copy of your code and any support files as a single tar file. (Include a copy of your Makefile. Yea, you should learn to use make(1) :) )
  4. A black-box test plan (remember in-out-rational!) and the output from the execution of your program on this test plan. (see script(1))
  5. A copy of your executable, named bt, placed in your home directory.

    Notes

    1. Elements of the tree should be little-black-book entries having a name (the key), phone number, and number of stars. Something like
        typedef struct littleBlackBookEntry *LittleBlackBookEntry;
        struct littleBlackBookEntry
        {
            char *name;
            char *phone_number;
            int stars;
        };
      
    2. Use the binary search tree order when inserting.
    3. Order names using strcmp(3) order.
    4. Better removals and insertions maintain tree balance; though, I'd get the program working otherwise before pondering this point.