Question: Delete the root node value of the BST and replace the root value with the appropriate value of the existing BST. [2] Perform the
Delete the root node value of the BST and replace the root value with
the appropriate value of the existing BST.
[2] Perform the BST status check by doing an In-Order Traversal of the
BST such that even after deletion the BST is maintained. you will explore a specific way to delete the root node of the Binary Search Tree (BST) while maintaining the Binary Search Tree (BST) property after deletion.
Very Very Important :
(1) Your code should be well commented which explains all the steps you are performing to solve the problem.
(2) As a comment in your code, please "Do a test-cases " on how you would test your solution assumptions and hence your code.

/* Class to represent Tree node */ class Node { int data; Node left, right; public Node(int item) { data = item; left = null; } right = null; The root element of the Binary Search Tree is given to you. Below is an illus- trated sample of Binary Search Tree nodes for your reference, which in-fact is the same example we discussed in the lecture. tree.root new Node (4); tree.root.left = new Node (2); tree.root.right = new Node (6); tree.root.left.left = new Node(1); tree.root.left.right = new Node (3); tree.root.right.left new Node (5); tree.root.right. right new Node (7); Your code will delete the root node value provided and replace the root value with appropriate value such that the BST property is maintaned which would be known by performing the In-Order Traversal of the new BST. Obviously, the In-order traversal of the resulting BST would need to be ascending order When you follow the deletion process and the BST traversal specified - the com- plexity of the solution will be as below. Time Complexity: O(n) Space Complexity: O(n)
Step by Step Solution
3.52 Rating (165 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
