Programming Assignment

Due:

Please make sure you adhere to the policies on academic honesty.

Please see the general programming webpage for details about the programming environment for this course, and specifically for directions in how to submit your programming assignment electronically.

The files you need for this assignment can be downloaded here.


Contents:

  • Overview
  • Representation
  • Two Different Drivers
  • Animating your routines (optional)
  • Our Advice
  • Files you will need
  • Files to Submit

  • Overview

    Your goal is to implement (2,4) trees, supporting insertion, deletion and searching. Chapter 9.4 of the text gives a high-level description of all of these operations. Your job will be to turn these ideas into a real program. Implementing deletion will be considered extra credit - worth 2 points.


    Representation

    Your program will need to make use of the following types of structures:


    Two Different Drivers

    We will be providing you with two different drivers which you may use in developing and testing your data structures.

    The first is a ``no frills'' text-based driver (TFDriver.java) which will simply offer a menu which lets you reinitialize a tree, search in a tree, or insert or delete items. The only output it will give is an echo of any return values provided by the operations. As we have done in the past, the default for this driver is to read commands from the keyboard. However, the program will accept an optional command line argument which is the name of a file to be used for specifying commands rather than the keyboard. The main advantage of this is that it allows you, when debugging, to type in a long combination of commands into a file, and then to run your program repeatedly on this set of commands (as opposed to having to type in all the commands from scratch each time you retest your program)

    The second driver we are providing is an applet (TFApplet.java) which can display a picture of your tree. Specifically, the applet will redraw the entire tree once, after each insertion or deletion is complete. It does not, by default, draw your tree in any of the intermediate stages which take place from within your routines. (see below for a way to do this!)

    This applet should be a great tool for you in developing your program as it allows you to see a view of your data structure. Of course, this view may show that your data structure is wrong or that you have not set pointers up correctly. If the picture does not look like you think it should have, then there is almost certainly a problem with your tree structure. If your program works correctly, you should be able to get pictures like those given in the book.


    Animating your routines (optional)

    As mentioned earlier, the applet only redraws the tree each time an insertion or deletion is completed. However it might be interesting if you are able to see a picture of your data structure at various points from within your code. This may help when developing your program, and it may make a more interesting animation when complete.

    We are providing you with a special function, Animation.Checkpoint() which provides exactly this feature. If you place a call to this method at various places within your code, and then you run the applet, the following behavior will occur. At each such call, the applet will redraw your tree in its current state, and then it will force a pause to the entire process, waiting for the user to click a button to continue. The text-based driver completely ignores these calls.


    Our Advice


    Files you will need

    The files you need for this assignment can be downloaded here.


    Files to Submit

    You should submit:

    If you define any additional classes, please submit the additional source code.


    Last modified: 15 November 2002