Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

8 class AVLNode 10 public comparable data; 11 public de left 12 public de righ 1

ID: 3862170 • Letter: 8

Question

8 class AVLNode 10 public comparable data; 11 public de left 12 public de righ 13 public int height; 14 15 default constructor 16e public AVLNode (Comparable value) 17 data value 18 left null 19 20 righ null 21 height 0; 22 23 24 parameterized constructor 25 public AVLNode (Comparable value de left1. AVLNode right 1) 26 data value 27 left left1. 28 29 right right1 30 heigh 0; 31 32 The ResetHeight method recomputes height if the 33 34 left or right subtrees have changed 35 void Reset Height) 36 37 int lefth eight -1; int rightheight -1; 38 39 if (left null) leftheight left. heigh 41 if (right null) rightheight righ height 42 43 heigh 1 ath. max (left height rightheight) 45 46 47 public class Tree 48 member attributes 49 private AVLNode root 50 private int size

Explanation / Answer


    private AVLNode CopyNode(AVLNode sourcend) {
        AVLNode left = null;
        AVLNode right = null;
        if (sourcend.left != null) {
            left = copy(sourcend.left);//copying left subtree
        }
        if (sourcend.right != null) {
            right = copy(sourcend.right);//copying right subtree
        }
        //creating new node...
        return new AVLNode(sourcend.data, left, right);
    }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote