Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to convert the following m-ary into its binary tree using Last Child Left Sibling method. A m-ary tree is a type of tree

I need to convert the following m-ary into its binary tree using Last Child Left Sibling method. A m-ary tree is a type of tree where every internal node has no more than m children. I cannot use any built in Java Collections Framework classes anywhere in your program such as ArrayList, LinkedList, HashSet, etc

image text in transcribed

Method Signature: public static BinTreeNode createBinTree(MTreeNode mroot) accepts a MTreeNode which is the root of the m-ary tree and returns the root of the binary tree created. Include this method in MTreeNode class. You will need to create BinTreeNode class for this task. An outline is given below:

Class Name: BinTreeNode Instance variables: 1. AnyType element 2. BinTreeNode lastChild 3. BinTreeNode leftSibling

Constructors: 1. public BinTreeNode (AnyType element, BinTreeNode lastChild, BinTreeNode leftSibling) 2. public BinTreeNode (AnyType el)

Methods: 1. public static int height(BinTreeNode> t) returns the height of the tree rooted at t and -1 if null 2. public static int size(BinTreeNode> t) returns the size of the tree rooted at t and 0 if null 3. public String toStringPreOrder() returns a String representation of a preorder walk on the binary tree rooted at this node. 4. public String toStringPostOrder() returns a String representation of a postorder walk on the binary tree rooted at this node. 5. public String toStringLevelOrder() returns a String representation of a level-order walk on the binary tree rooted at this node. 6. Again, all walks are from right to left as compared to the traditional left to right.

Example Outputs of tree traversals on the binary tree given on the right: Pre-order: A D F L K E C B I J H G Post-order: K L E F J G H I B C D A Level-order: A D F C L E B K I J H G

From To Method Sionature

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

=+5 Does this case provide an example of the future for IHRM?

Answered: 1 week ago

Question

=+4 How did it affect HR?

Answered: 1 week ago