Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Objective: Implement the BST ADT as a Platform Developer Background: Be sure to read the related Lecture deck and the recommended textbook before starting this assignment

Objective: Implement the BST ADT as a Platform Developer Background: Be sure to read the related Lecture deck and the recommended textbook before starting this assignment

Computer Science

Objective: Implement the BST ADT as a Platform Developer Background: Be sure to read the related Lecture deck and the recommended textbook before starting this assignment.

 

PartA: (80 points) Your assignment is to add SIX methods to the BST struct: getHeight(), getNumberOfNodes(), getNumberOfLeaves(), and inorder, preorder and postorder tree traversals. You should calculate the tree height, number of nodes and number of leaves using recursive methods. The Function prototypes should be: int getHeight(); int getNumberOfNodes() ; int getNumberOfLeaves(); It is recommended that each of these methods will call a method whose parameter is a pointer to a node that is the root node of the subtree that remains to be processed. getHeight() Your lecture notes describes the getHeight() method and includes the algorithm. Note that an empty tree has a height of -1 and a tree with a single node has a height of zero. getNumberOfNodes() The getNumberOfNodes method will be very similar to the getHeight method. The base case occurs when the subtree is empty. An empty tree has no nodes (method returns zero). The recursive case when the subtree is not empty. The method should return 1 (for the root node of the subtree) plus the number of nodes in the left subtree (recursive call) plus the number of nodes in the right subtree (recursive call). getNumberOfLeaves() A leaf node is a node that has no children. To count the number of leaves, you will need two base cases. If the subtree is empty, it contains no leaves (return zero). If the subtree consists of a node with no children, that node is a leaf (return one). For the recursive case, the root node of the subtree is not a leaf. Return the number of leaves in the left subtree (recursive call) plus the number of leaves in the right subtree (recursive call). In addition, you will need to implement the inorder, preorder and postorder tree traversals. Mandated List of Integers for Building the BST in the following order: 60, 20, 70, 10, 40, 50, 30. Enter the above integers from terminal and build the BST from scratch, perform the inorder, preorder and postorder tree traversals, report the height, number of leaves and nodes after data entry. Your program should display the horizontal hierarchy of the BST. You can then perform the deletion of item(s) in the BST, perform the inorder, preorder and postorder tree traversals, and report the the height, number of leaves and nodes after item deletion. Your program should display the horizontal hierarchy of the BST.

 

Part B: (20 Points) Build a 6 level complete and balanced BST, remove the root. Perform the inorder, preorder and postorder tree traversals and report the the height, number of leaves and nodes after item deletion. Your program should display the vertical hierarchy of the BST.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE