Java program to create a tree
Course:- JAVA Programming
Reference No.:- EM13463

Assignment Help
Expertsmind Rated 4.9 / 5 based on 47215 reviews.
Review Site
Assignment Help >> JAVA Programming
You will need a BottomUpTwoThreeFourTree class, with a BottomUpTwoThreeTreeFourTree constructor which takes no parameters.
BottomUpTwoThreeTreeFourTree will need an insert(int x) method, which will insert the value x into your tree. For this tree, duplicate insertions should be discarded. That is, if I insert a value into the tree which is already in the tree, do not change your tree. As discussed in class, if a node needs to split, the value passed up to the parent should be the median value of the three keys in the node, before the 4th key is added.
BottomUpTwoThreeFourTree will need a search(int x) method, which will search for the value x in your tree. The method should return a String, formatted as follows. If the value x is in the tree, it will reside in a node with either one, two, or three keys. For a one key node, the string will just be that node's key as a String. If it is a two key node, the string should be the two values, in increasing order, with a single space between them. Finally, three keys should be returned with a single space between each pair, in increasing order. Example: if we are searching for the number 17, and it is a key alone in a node, the search function should return "17". If it is in a node with 35, you should return "17 35". If it is in a node with 10, you should return "10 17". And, if it in a node with keys 10 and 35, you should return "10 17 35". Note, there is no space after the last key value.
If the value searched for is not in the tree, your search should have terminated at a leaf node. In that case, print the contents of that leaf node, with the same formatting described above. That is, if 17 is not in the tree, and you end in a node that contains keys 18 and 20, return "18 20".
You need to submit your own JUnit tests as well, again in a file with a name ending in Test.java or Tests.java. Your main grade will be based on (a) how well your tests cover your own code, (b) how well your code does on your tests, and (c) how well your code does on MY tests. If you fail even one of my tests, I will set up my tests to make sure that you fail many of them. If you know that your code has an error, it is hard to consider your code as "working"

Put your comment

Ask Question & Get Answers from Experts
Browse some more (JAVA Programming) Materials
Which of the following relationships is not a correct example of inheritance?  Parent to Children  Aunt to Uncle  Grandparent to Grandchild
Write an ISR and startup code for a system that lights up LED0 on the PSoC Eval1 board (assuming that a wire is connecting P1[0]) to show "Low Voltage" whenever there is a s
Write a class Sorter which contains methods for selection sort, insertion sort and bubble sort (start with the code below). Then create a client class which asks user to ent
Do some research on Java application and Java applet. What are the differences and connections between these two? To find out, you might need to be more resourceful than usu
Based on the feedback received for Question 3 in Assignment 1, transform your algorithm into a JAVA program. Your code should contain appropriate validations and must focus
Add a draw() method to your Horse class. You will also need to create a couple of Horses in your DrawPanel class, and call the draw() method for each Horse from the paintCompo
Define a class DateTime which has integer attributes day, month, year and time(Use Military time, 1:00pm is 1300, no colon). Make DateTime Serializable and Comparable.
Write a program ArrayProcessing.java that reads a file name from the keyboard. The file contains integers, each on a separate line. You then create a corresponding array with