Programming Assignment In this assignment you have to implement some basic Java methods for BST's (with a little twist)
Posted: Sat Nov 27, 2021 2:17 pm
Programming Assignment In this assignment you have to implement some basic Java methods for BST's (with a little twist) and an iterator (i.e., an inorder sequencing). Each node in the tree has a data element (an integer) and links (possibly null) to its left and right children (as mentioned above, no parent link and no external node). 1
In this assignment, you will have to implement the basic functions needed to build and search binary search trees (BST). Your implementation should be such that the nodes of the tree contain an integer and links (possibly null) to the left and right children of the node. It is strongly recommended that you do Paper Exercises 1 and 2 before you start the programming part of the assignment. Paper Assignment 1. Binary Search Trees(BST) (a) Draw the BST where the data value at each node is an integer and the values are entered in the following order. 36, 22, 10, 44, 42 (b) Draw the BST after the following insertions have been done in the tree of part (a): 16, 25, 3, 23, 24 (there is no attempt at being tricky; parts (a) and (b) could be combined into a single one but we want you to check your work so that you don't make a silly mistake) (c) Now draw the tree after deletions of 42, 23 and 22 in this order (d) Write down the order on which the node values are reached when the BST of part (C) is traversed (i) in inorder (ii) in postorder (iii) in preorder (e) What is the height of the tree of part (c)? Which nodes have maximal depth in the tree of part (c)? Programming Assignment In this assignment you have to implement some basic Java methods for BST's (with a little twist) and an iterator (i.e., an inorder sequencing). Each node in the tree has a data element (an integer) and links (possibly null) to its left and right children (as mentioned above, no parent link and no external node).