Question: Write a function that takes as input a general tree and returns the number of nodes in that tree. Write your function to use the
Write a function that takes as input a general tree and returns the number of nodes in that tree. Write your function to use the GenTree and GTNode ADTs of Figure 6.2.

/** General tree ADT */ interface GenTree { public void clear(); public GTNode root (); // Clear the tree // 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.19 Rating (144 Votes )
There are 3 Steps involved in it
Based on the provided image which shows an interface for a general tree ADT we can write a function that calculates the number of nodes in the tree Si... View full answer
Get step-by-step solutions from verified subject matter experts
