Question: Class Name: MTreeNode Instance variables: 1. AnyType element 2. int m 3. ArrayList children Constructors: 1. public MTreeNode (AnyType element, int m, ArrayList children) 2.

Class Name: MTreeNode Instance variables: 1. AnyType element 2. int m 3. ArrayList children Constructors: 1. public MTreeNode (AnyType element, int m, ArrayList children) 2. public MTreeNode (AnyType el, int m) where element represents values or elements of type AnyType, m is the branching factor which is 3 in 3-ary trees and 4 in 4-ary trees, and an array containing a total of m or less children. Methods: 1. public static int height(MTreeNode t) returns the height of the tree rooted at t and -1 if null 2. public static int size(MTreeNode t) returns the size of the tree rooted at t and 0 if null 3. public boolean addChild(MTreeNode child) adds the child to the list of children; returns true if child is added, false if the array is full thus cant add more children 4. public String toStringPreOrder() returns a String representation of a pre-order walk on the m-ary tree rooted at this node. 5. public String toStringPostOrder() returns a String representation of a post-order walk on the m-ary tree rooted at this node. 6. public String toStringLevelOrder() returns a String representation of a level-order walk on the m-ary tree rooted at this node. Hint: Use a queue.

All walks are from right to left as compared to the traditional left to right.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!