Description
This assignment is to finish the Binary Search Tree (BST)
implementation discussed in class. You will find the code attached
to the assignment. You may use any code already implemented in the
BST class to assist with your task (e.g has(), findRecursive(),
etc).
Requirements
You will implement four operations: remove a node, compute
height of the tree, and preorder and postorder traversals. Detailed
requirements for each are given below. You may tackle these
operations in any order; some of them are easier than others, and
can serve as a warm-up.
Removal should be implemented in the method remove(Integer).
Your solution needs to follow the algorithm discussed in the
textbook and slides. Note that the argument provided to remove need
not actually be present in the tree - it is your job to detect this
situation and handle it appropriately.
Height computation should be implemented in the method height().
You may implement this in any way you see fit, though the algorithm
from the textbook may prove useful to adapt here.
Finally, the traversals should be implemented in methods
preorder() and postorder(), respectively. The existing
implementation for the inorder traversal should be helpful as a
guide.
Code Template
You can start with the attached Java file. Due to its length, it
is not reproduced here
Description This assignment is to finish the Binary Search Tree (BST) implementation discussed in class. You will find t
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Description This assignment is to finish the Binary Search Tree (BST) implementation discussed in class. You will find t
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!