Programming Homework Help

Programming Homework Help. San Jose State University Binary Tree Exercises

 

Binary search tree data structures is a simpler design than normal tree data structures. A binary search tree node basically consists of a left and right node property, a parent node property, and an object type data value. Your objective is to build a binary tree with capabilities of being able to search for a node that contains a specific data value, adding of new binary tree nodes, and removal of binary tree nodes.

TO DO #1

Write a Runner.java class that does the following as shown in main, and then build your binary search tree as needed.

public static void main(String args[]) {

// Go through the for loop and a build a tree based on the elements in the array

// Build the tree as you traverse the array in order

// When building a binary search tree, the first number in the list is typically the root

ArrayList<String> listOfNumbers = new ArrayList<Integer>(

Arrays.asList(20,

30,

40,

15,

10,

11,

25,

32,

5

);

)

// TO DO #2: Create your data object class (call the class ItemData). This class needs to

// have these 2 data properties:

// a) an array value

// b) the array value (above) plus the ASCII (capaital) decimal value of the first

// letter of your last name. This is a sum value. Let’s call it an encoded value.

// ASCII table can be found at:

// http://www.asciitable.com/

// TO DO #3: Create your binary search tree node (call this class BSTNode)

// – research the power point slide and figure out how to create BST node

// TO DO #4: Cycle through the above array and build your binary search tree

// hint you need to perform add/insertion of a node

// TO DO #5: After you build the tree, do a search for the number 25, and when the BST node

// is found, print out the following:

// a) all of the properties of the ItemData object (there are only two)

// b) the ItemNode data of the left and right BST nodes

// TO DO #6: Search for an ItemData that doesn’t exist i.e. choose the number 100 for

// searching. If there isn’t a BST node with the ItemData that you are looking for,

// You should print out i.e. “100 not found”

// TO DO #7: Remove the BST node that contains the number 5 (this is a leaf node)

// TO DO #8: Print the current contents of the tree

// – you can get some ideas from the recursion method in the Week 16

// powerpoint slide called “Iteration”

// – see below link for the concept:

// https://www.tutorialspoint.com/data_structures_algorithms/tree_traversal.htm

// – Which traversal do you think this power point slide is representing??

// You will print out the value in two ways

// a) the encoded property value (this is decribed in To Do #1)

// b) the actual array value assuming the decoding key is provided (this key is the

// first letter of your last name)

// ADD print statements to describe the flow of main. Make main to tell a story.

}

This is all of the hints/info you are getting. You will add whatever you think is needed for the classes above to make this work. It’s your design. It’s your creation but follow the minimum requirements mentioned in the TO DO list.

In a nutshell, you will write classes, and write code (in main) for each of the TO DO items; Basically you will be demonstrating the features of your application. You must write the code in the order described in the main method.

Programming Homework Help