Question: Use Java program to implement it. Study the three Java source files. as listed BELOW Create a project in eclipse to run the code. Then,

Use Java program to implement it. 

Study the three Java source files. as listed BELOW

Create a project in eclipse to run the code.

Then, modify the code so that it creates and prints the tree in the "Binary Tree.doc" file as shown BELOW

 1. /** This program demonstrates construction and traversal of binary trees. */ public class BinaryTreeNodes { // Creates a binary tree from nodes and traverses it in // in inorder. public static void main(String[] args) { Node root = null; // Will be root of the binary tree. Node aNode = new Node(10); aNode.left = new Node(20); Node dNode = new Node(40); Node cNode = new Node(30, dNode, new Node(50)); aNode.right = cNode; root = aNode; System.out.print("Inorder traversal is: "); NodeUtilities.inorder(root); System.out.println(); } } 

2.

/** Node class. */ public class Node { int value; Node left, right; // Constructor for leaf nodes. Node(int val) { value = val; left = null; right = null; } // Constructor for non-leaf nodes. Node(int val, Node leftChild, Node rightChild) { value = val; left = leftChild; right = rightChild; } } 

3.

/** This class has various utility methods for working with nodes. */ public class NodeUtilities { /** Inorder traversal of a binary tree rooted at a node. @param btree : The root of the binary tree. */ static public void inorder(Node btree) { if (btree != null) { inorder(btree.left); System.out.print(btree.value + " "); inorder(btree.right); } } } 

"Binary Tree.doc"

Use Java program to implement it. Study the three Java source files.

..|..1..|.. 2 ..|.3 ..:.. 4 ...|..5..|..67. D Binary Treesnap 90 100

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!