This homework is due before class on March 23.
This homework is about trees.
k in part 6)
To test your tree datatype, construct a loop that reads characters from a string. The program should recognize three characters that have the following interpretation:
l': descend left from the current node. If the left
child of the current node does not exist, create it and set it as
the current node.
r': descend right from the current node. If the right
child of the current node does not exist, create it and set it as
the current node.
u': move to the parent of the current node. Handle the
case when the current node is the root.
After every operation, print the ID of the current node; node creation
should increment the node ID.
You may also want to log all operations such as movement in the tree, etc. For example, the string "llurur" might print:
At node #0
Created left leaf with ID #1 for node #0
Created left leaf with ID #2 for node #1
Moved up to node #1
Created right leaf with ID #3 for node #1
Moved up to node #1
Moved right to node #3
You may intially create a single root node to get the process started.
Pass the string to interpret as args[0] to main.
The DrawTree applet of lab 7 may be useful in verifying that your trees are correctly constructed.
Hand in: answers to Part I; code and scripts for Part II.
Be sure to include documentary comments in your code.
instructions on how to submit