Question: Hi, Please combine this two JAVA program into one program. Few of the part of the program is already given by Screen shot under the

Hi, Please combine this two JAVA program into one program. Few of the part of the program is already given by Screen shot under the Quenstion. There it's already says What codes are you have to write.. Please make sure to use main method and same output that is given. Make sure the program works. Please finish this program as soon as possible. Thank You...

8.1 Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children. Dont worry if the tree is unbalanced. Note that this will not be a search tree; theres no quick way to find a given node. You may end up with something like this:

One way to begin is by making an array of trees. (A group of unconnected trees is called a forest.) Take each letter typed by the user and put it in a node. Take each of these nodes and put it in a tree, where it will be the root. Now put all these one-node trees in the array. Start by making a new tree with + at the root and two of the one-node trees as its children. Then keep adding one-node trees from the array to this larger tree. Dont worry if its an unbalanced tree. You can actually store this intermediate tree in the array by writing over a cell whose contents have already been added to the tree. The routines find(), insert(), and delete(), which apply only to search trees, can be deleted. Keep the displayTree() method and the traversals because they will work on any binary tree.

8.2 Expand the program in Programming Project 8.1 to create a balanced tree. One way to do this is to make sure that as many leaves as possible appear in the bottom row. You can start by making a three-node tree out of each pair of onenode trees, making a new + node for the root. This results in a forest of threenode trees. Then combine each pair of three-node trees to make a forest of seven-node trees. As the number of nodes per tree grows, the number of trees shrinks, until finally there is only one tree left.

Hi, Please combine this two JAVA program into one program. Few ofthe part of the program is already given by Screen shot under

* You need to write classes Node, Tree, BottomUp, and BottomUPARR with main method */ public static void main(String[l] args) throws IOException BottomUp bup: Tree theTree = null; int value; String str: while(true) System.out,print("Enter first letter of balanced, "); System.out,print("unbalanced, show, or traverse: ") int choice = getchar(); switch(choice) case 'b System out print("Enter string: "): str = getString(); bup-new BottomUp(str) bup.balanced) theTree = bup.getTree(); break; case 'u': System.out.print("Enter string: ") str = getString(); bup-new BottomUp(str); bup.unbalanced) theTree-bup.getTree) break; case 's' theTree.displayTree) break; case 't: System.out.print("Enter type 1, 2 or 3: "); value = get! theTree.traverse(value) break; nt(); default System out.print("Invalid entryn"); l end switch end while end main() The output may look like

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!