Question: Must use the Java class TNode given to implement tree nodes. Need help writing the 'public void printNonRec()' method. It must be nonrecursive and uses
Must use the Java class TNode given to implement tree nodes. Need help writing the 'public void printNonRec()' method. It must be nonrecursive and uses a stack to implement inorder traversal. Please provide comments thanks!



Class BSTSet must contain only one private field named root, of type TNode, which is a reference to the root of the tree. No other fields are allowed. When the set is empty you should have root==null. nodes you must use the Java class TNode provided in this lab. Additionally, you may need to implement Java classes MyStack and/or MyQueue to perform non-recursive tree traversals of a BSTSet. You are not permitted to use any predefined Java methods or classes from Java API, other than for input and output, unless specified otherwise. public class TNode{ int element; TNode left; TNode right; TNode (int i, TNode 1, TNode r) { element ri; left = 1; right = r; } }//end class public void printNonRec(): Prints the integers in this BSTSet in increas- ing order. This method is nonrecursive and uses a stack to implement the inorder traversal. Class BSTSet must contain only one private field named root, of type TNode, which is a reference to the root of the tree. No other fields are allowed. When the set is empty you should have root==null. nodes you must use the Java class TNode provided in this lab. Additionally, you may need to implement Java classes MyStack and/or MyQueue to perform non-recursive tree traversals of a BSTSet. You are not permitted to use any predefined Java methods or classes from Java API, other than for input and output, unless specified otherwise. public class TNode{ int element; TNode left; TNode right; TNode (int i, TNode 1, TNode r) { element ri; left = 1; right = r; } }//end class public void printNonRec(): Prints the integers in this BSTSet in increas- ing order. This method is nonrecursive and uses a stack to implement the inorder traversal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
