Q136
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.right = insert (x, wt, k.right) if (k.right.weight < k.weight) k = rotateWithLeftChild (k)
A.
when x>t. element Rotate-with-left-child should take place and vice versa
AnswerB.
the logic is incorrect
C.
the condition for rotating children is wrong
D.
insertion cannot be performed in weight balanced trees
Answer: Option A
Solution
Answer: Option A
No explanation is given for this question Let's Discuss on Board