ExamVeda
Login
Home
Binary Search Trees(B Tree)
?

Why the below pseudo code where x is a value, wt is weight factor and t is root node can't insert?
WeightBalanceTreeNode insert(int x, int wt, WeightBalanceTreeNode k) :
 
   if (k == null)
        k = new WeightBalanceTreeNode(x, wt, null, null)
   else if (x < t.element) :
 
        k.left = insert (x, wt, k.left)
        if (k.left.weight < k.weight)
            k = rotateWithRightChild (k)
 
    else if (x > t.element) :
 
        k.right = insert (x, wt, k.right)
        if (k.right.weight < k.weight)
            k = rotateWithLeftChild (k)

Answer & Solution
Correct Answer: Option A
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.