> > Write a non-recursive method to insert a node in a binary tree.
> 
> Is the binary tree we're inserting into sorted?
> 
> If so, on what?  Should we keep it that way?
> 
> --Dan Keshet

Dan -
        Good question.

        This is a pen-and-paper assignment.  I would suggest
you take the Tree insertion from the notes, and modify it
to be non-recursive.

        On an unrelated note, the Tree programs are the first
we have handed out that involve a couple of interfaces.
Every semester some folks run into problems compiling these
programs.  Here are my directions from last semester.

Duplicate the structure
        TreeSort.java
        tree    <directory)
        tree/TreeKey.java
        tree/Tree.java
        
% mkdir tree-sort
% cd tree-sort
% mkdir tree
% cd tree
% mv /tmp/TreeKey.java .
% mv /tmp/Tree.java .
% cd ..
% mv /tmp/TreeSort.java .
        Create a sample data file: I use TreeKey.java below
% cp tree/TreeKey.java data

                Compile everything
% cd tree
% javac TreeKey.java Tree.java
% cd ..
% javac TreeSort.java
Note: TreeSort.java uses a deprecated API.  Recompile with "-deprecation"
for details.
1 warning
% java -classpath ".:tree" TreeSort data

Pretty Print
....


- jeff parker

Reply via email to