Question: 2. [5 pts] Billy wrote the following algorithm whose purpose to test whether or not a given BST is AVL compliant: int getHeight(TreeNode root) {

 2. [5 pts] Billy wrote the following algorithm whose purpose to

2. [5 pts] Billy wrote the following algorithm whose purpose to test whether or not a given BST is AVL compliant: int getHeight(TreeNode root) \{ if ( root == null) \{ return 0 ; \} int left_height = getHeight ( root.getLeftchild()) ; int right_height = getHeight ( root.getRightchild()); // assume MAX() returns the maximum value return MAX(left_height, right_height) + 1; \} bool isAvl(TreeNode root) \{ if (root == null) return true; int left_height = getHeight ( root.getLeftchild()); int right_height = getHeight ( root.getRightchild()); //assume ABS() returns the absolute value int difference = ABS (left_height - right_height) ; if(difference > 1 ) \{ return false; \} return true; \} A. [2 pts] What is the runtime complexity of Billy's isAvl() function? Answer. B. [3 pts] Unfortunately, his code doesn't work in every case Explain why with a sample tree

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!