CSC 201 Grinnell College Spring, 2005
 
Data Representation, Memory Management, and Formal Methods
 

Modifying Tree Structures

Goals

This laboratory builds on the previous lab to provide experience modifying tree structures.

Details for This Lab

This lab continues work on program ~walker/c/trees/bst.c that contains a program shell for managing the insertion and print operations for a binary search tree.

  1. Expand the stub for procedure addNameRec that uses a recursive algorithm to insert a name into a tree. As this algorithm is recursive, you will need to identify a simple base case. The recursive case should ask for insertion further downward in the tree. In many respects, the algorithm parallels the recursive function findRec. However, in this case, the root of a tree might change, so the rootPtr parameter must contain the address of the root.

    As in other work, your work should involve changing function addNameRec (adding additional functions if needed), but leaving other existing functions unchanged.

  2. Expand the stub for procedure deleteName that removes a designated name from the tree. The algorithm utilizes both recursion and iteration, as outlined in class. Be sure you understand the algorithm thoroughly before you start to code.

Work to turn in


This document is available on the World Wide Web as

     http://www.cs.grinnell.edu/~walker/courses/201.sp05/lab-bst-operations1.shtml

created September 27, 2001
last revised February 19, 2005
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.