Question: Task Using sample code provided, code additional methods to add functionality _____________________________________________________________________________________ Detailed requirements: You are provided the sample code for the

Task       Using sample code provided, code additional methods to add functionality

_____________________________________________________________________________________

Detailed requirements: 

  • You are provided the sample code for the following classes:
    • BinaryTreeNode o BinaryTree o BinaryTreeTest

 

  • Your tasks are to:
    • Create an array to store these int values:

26 38 34 33 70 11 25 72 14 51                   

13 77  6 40 95 84 50 35 31 54  

88 74 46 86 57 39 85 80 19 92  

  • Start with an empty Binary Search Tree (BST) and use the array above along with a loop to insert the values into the BST.

Do not use dozens of lines containing insertInTree() !!

 

  • Display the contents of the BST using in-order, pre-order and post-order traversal
  • Hint: use the sample in-order traversal method
    • and write your own method to perform pre-order traversal ▪
    • and write your own method to perform post-order traversal ▪
    • Your output must include in-order, preorder and post-order output.

 

  •  a method using iteration to search for a specific value following this method signature:   public boolean search(int key)
    • Test your methods using the values seen in the Sample Output.
    • Your results and format of output must match the Sample Output ( be sure to include the post-order output)
  • Notes:

o You may alter main() o And you may make minor changes to the sample code. Sample Output:         see .jpg from on Brightspace

Coding & Submission Requirements: 

  • follow the Java Coding Conventions as your "style guide"
  •  at least 2 classes o name of the class with the main() method must end in "Test"
  •  at least 2 packages
  • export your Eclipse project as a .zip

o name your file Lab5_Firstname_Lastname.zip

o also, be sure to name your Eclipse project according to the form: 

Lab5_Firstname_Lastname

  •  
  • (substitute your own first and last names, of course)

Note:

  • You will lose marks if you do not:
    • follow the instructions under Detailed Requirements

▪   including any algorithms described

o meet the Coding requirements

o ensure there are complete Javadoc comments for all public constructors and methods.

  •  
  • produce the kind of output shown in the partially complete Sample output - ( be sure to include the post-order output)

In addition to the provided output, add a method to generate and display Tree elements in post-order traversal as part of your complete output

Step by Step Solution

3.51 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Create a class BinaryTreeNode with attributes for data left child and right child Create a class Bin... View full answer

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 Programming Questions!