Question: class Node { public char key; // key-id value public Node left; // left child public Node right;// right child // constructor public Node(char key)

class Node {
public char key; // key-id value
public Node left; // left child
public Node right;// right child
// constructor
public Node(char key) {
this.key = key;
left = null;
right = null;
}
}
//////////////// Binary Tree class
class BTree {
private Node root;// Ref. root
/// TO COMPLETE
////// methods (Show the Tree)
private void recShow(Node current,String indStr){
if (current!=null){
recShow(current.right,indStr+" ");
System.out.println(indStr+current.key);
recShow(current.left,indStr+" ");
}
}
public void show(){
System.out.println("The tree looks like: ");
recShow(root," ");
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
class TreeApp{
////// Transform an array of Character into a Binary Tree
////// character '-' means that the node is null
public static void main(String[] args)
{
char[] array;
//array= new char[]{'p'............}; // TO COMPLETE
BTree mytree = new BTree(array);
mytree.show();
}
}
HW4- ECE 242 - Fall 2017 Binary Search Tree 5pts Bonus) Within the first 10 minutes of discussion, run your code in front of the TA 1- Complete the code TreeApp.java you need to implement a constructor for the BTree class as well as the insert methods. The Show methods (to plot the tree with 90degree angle) are provided. In the main method, you need to complete the array of character that provides the following tree: The tree looks like: Remark: If you have a valid excuse (doctor letter, etc. see syllabus) and cannot come to discussion, you can e-mail your code and excuse before your discussion section, to your respective TA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
