Introductory Laboratory on Binary Search Trees


Introduction to Binary Search Trees

Summary: This laboratory provides some experience using a binary search tree structure.

Program /home/walker/public_html/courses/152.sp01/BST.java contains a simple class shell, including the insertion and print operations for a binary search tree. All declarations and operations follow material discussed in the text and in class. The program also contains various method stubs for additional operations.

  1. Copy this program to your account.

  2. Expand the stub for an iterative findIt method, which returns whether a given node appears in the tree. In this process, you should change only the findIt method, adding additional methods as needed, but you should not change any other existing procedures. (I.e., if something is not broken, do not fix it!) Also, note that this method is to be iterative -- recursion is NOT allowed in writing this method.

  3. Expand the stub for a recursive findRec method, which is the recursive version of findIt. (In implementing findRec, you may want to consider findRec as a husk and implement a private method as the kernel.)

  4. Develop a collection of test data to test the various method thoroughly. What types of cases should be considered? What supporting evidence is necessary to support a claim that the resulting program is correct?


This document is available on the World Wide Web as

http://www.cs.grinnell.edu/~walker/courses/152.sp01/lab-bst-intro.html

created April 17, 2001
last revised April 17, 2001
Henry Walker (walker@cs.grinnell.edu)