prepare a program that constructs a binary tree


Prepare a program that constructs a binary tree and traverses the tree in pre-order, in-order and post-order methods. Your program must also give the height of the tree. Your program must implement proper object oriented and data structure basic concepts (use interfaces and implement the required primitive operations).

The input must be read from a file. Suppose the nodes store positive numbers and have no duplicates. On every line of input file specify the node, its parent, its left child, and right child. A -1 must be used to show absence of a parent, left child, or right child. Below are some examples of sample input line with explanation:

0 -1 1 2 #Node stores 0 with no parent and has left child and right child that stores values 1 and 2.

1 0 3 4 #Node that stores 0 is parent of 1 and nodes left and right child store 3 and 4.

Here is sample text that must be in your input file

0 -1 1 2
1 0 3 4
2 0 5 6

Write your own implementation of primitive operations and use self-referential classes in your implementation.

Make sure your code runs from command line and specify which version of java was used along with the commands to compile and run your code. Failure to properly document your code will result in penalty.

Also make sure you upload a compressed version of your folder, please use .zip compression format. Your folder must contain only the java source files, please do not include any other kind of files such as jar files, class files, any input text files etc.

Your assignment will be graded based on following structure:

1. Implementation of data structure
2. Implementation of traversal techniques
3. Implementation of finding the height of tree
4. Documentation and indentation

Solution Preview :

Prepared by a verified Expert
JAVA Programming: prepare a program that constructs a binary tree
Reference No:- TGS0445823

Now Priced at $40 (50% Discount)

Recommended (91%)

Rated (4.3/5)