Prepare a program that constructs a binary tree and

Assignment Help JAVA Programming
Reference no: EM13350312

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

Reference no: EM13350312

Questions Cloud

Questiona hunter wishes to cross a river that is 25 km wide : questiona hunter wishes to cross a river that is 2.5 km wide and that flows with a speed of 4.8 kmh. the hunter uses a
Question1a step-up transformer has 270 turns on its primary : question1a step-up transformer has 270 turns on its primary coil and 90000 turns on its secondary coil. the emf of the
Question1a playground merry-go-round of radius r 180 m has : question1a playground merry-go-round of radius r 1.80 m has a moment of inertia i 255 kg.m2 and is rotating at 8.0
Questionair has a small regularly negligible index of : questionair has a small regularly negligible index of refraction. it is 1.0002926. this causes the sun to actually be
Prepare a program that constructs a binary tree and : prepare a program that constructs a binary tree and traverses the tree in pre-order in-order and post-order methods.
Question1a space station in a form of a large wheel 271m in : question1a space station in a form of a large wheel 271m in diameter rotates to provide an artificial gravity of 2.6
Qestion1a 100-kg beaker containing 209 kg of oil density : question1a 1.00-kg beaker containing 2.09 kg of oil density 916 kgm3 rests on a scale. a 1.99-kg block of iron is
Management has already signed the contract and committed to : management has already signed the contract and committed to a project whichhas a large negative net present value. this
Question1a space station is constructed in the shape of a : question1a space station is constructed in the shape of a wheel 20 in diameter with essentially all of its 5.1times105

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program to simulate the behavior of the philosophers

Write a program to simulate the behavior of the philosophers, where each philosopher is a thread and the chopsticks are shared objects.

  Prompts the user for three first names

Write an application that prompts the user for three first names and concatenates them in every possible two-name combination so that new parents can easily compare them to find the most pleasing baby name. Save the file as BabyNameComparison.java

  Write and run a java program

Write and run a Java program which allows the user to input two doubles and outputs the greater of the two?

  Calculate rental fee for different types of borrowable media

Assume that there is an abstract class called Vehicle, which has two concrete subclasses, Car and Truck. There is also an interface Loadable, which only Truck implements - calculate a rental fee for different types of borrowable media (e.g. books,..

  Write a reference class called ctatrain

writing a reference class that consist of the 2nd and 3rd instance variables below. my class should consist of an array of values in the 2nd instance variable

  File integrity checker - tripwire

Write a program that will perform some of the basic tasks accomplished by a file integrity checker such as Tripwire.

  Why is the order of the execution of two processes important

Modify the code so that the senderReceiver process sends then receives repeatedly suspending itself for 3 seconds between each iteration.

  Menu based program to maintain student records

Write a menu based program to maintain student records. Your program should take the following inputs: 1. Student first name (max. 20 characters) 2. Student last name, (max. 20 characters) 3. Student scores (float/double), eg. 85.4 Problem

  Design and implement a small and simple email server

Design and implement a small and simple email server using the concept of web based information system (WBIS).

  Use inheritance to read, store, and print questions for test

use inheritance to read, store, and print questions for a test. First, write an abstract class

  Discuss factors that affect sorting in sediment

Discuss factors that affect sorting in sediment. How could one tell the latitude at which a sediment was originally deposited? Compare and contrast phosphate and manganese nodules.

  Primary care-secondary care and tertitary care

Discuss the differences among primary care, secondary care, and tertitary care and the 6 C's of primary care

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd