Question: Write classes that implement the general tree class declarations of Figure 6.2 using the linked general tree implementation with child pointer arrays of Figure 6.12.
Write classes that implement the general tree class declarations of Figure 6.2 using the linked general tree implementation with child pointer arrays of Figure 6.12.

Your implementation should support only fixed-size nodes that do not change their number of children once they are created.

Then, reimplement these classes with the linked list of children representation of Figure 6.13. How do the two implementations compare in space and time efficiency and ease of implementation?

/** General tree ADT */ interface GenTree { public void clear(); // Clear the tree. public GTNode root (); // Return the root // Make the tree have a new root, give first child and sib public void newroot (E value, GTNode first, GTNode sib); public void newleftchild (E value); // Add left child } Figure 6.2 The general tree node and general tree classes.
Step by Step Solution
3.39 Rating (149 Votes )
There are 3 Steps involved in it
class GTNode E value GTNode firstChild GTNode nextSibling public GTNodeE value thisvalue value thisf... View full answer
Get step-by-step solutions from verified subject matter experts
