Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A full trinary tree has no missing nodes, i.e., all interior nodes have three children and all leaf nodes are at the same level as
A full trinary tree has no missing nodes, i.e., all interior nodes have three children and all leaf nodes are at the same level as shown in these examples:
A A A /|\ /|\ B C D / | \ / | \ B C D /|\ /|\ /|\ E F G H I J K L M
Implement the generic isFullTriTree method below so that it returns true if the trinary tree is full, false otherwise.
public staticboolean isFullTriTree(TrinaryTreenode n) { //TODO: COMPLETE THIS METHOD }
The method is passed a reference to a TrinaryTreenode that is the root of the tree.
The TrinaryTreenode class is implemented as partially shown below:
class TrinaryTreenode{ // *** fields *** private T data; private TrinaryTreenode leftChild; private TrinaryTreenode midChild; private TrinaryTreenode rightChild; // *** methods *** public T getData() { return data; } public TrinaryTreenode getLeft() { return leftChild; } public TrinaryTreenode getMid() { return midChild; } public TrinaryTreenode getRight() { return rightChild; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started