Question: ( 1 ) Modify the BST so that it can keep track of its balance. For the purpose of this question, a balanced tree is
Modify the BST so that it can keep track of its balance. For the purpose of this question, a
balanced tree is defined to be a tree such that the heights of the two subtrees of any node
never differs by more than one.
You are expected to create a new field in each node which stores the balance of the node.
Note, when a node is inserted and deleted, the balance must be updated.
Write a function to test the balance of a tree, which returns True or False depending if the
tree is balanced or not.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
