Question: 3. (a). [6 marks] Fill in the missing code below from the Sedgewick book's implementation of a right rotation for a Red-Black tree. The Node
![3. (a). [6 marks] Fill in the missing code below from](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f093f727584_55066f093f6903cd.jpg)
3. (a). [6 marks] Fill in the missing code below from the Sedgewick book's implementation of a right rotation for a Red-Black tree. The Node class is given. Recall that you have access to global final variables RED = true and BLACK = false and the helper method size (Node h) which returns the number of internal nodes in the tree rooted at h. private class Node Key key; Value val; Node left, right; int Ni boolean color; // key // associated value // subtrees // # of nodes in subtree // color of parent link Node rotateRight (Node h) Node x-h.left; // two assignments to adjust 1inks h.left - x.right - // two assignments to adjust colour h,color = // two assignments to adjust N, the number of descendents h.N return x (b). [4 marks] Given a Node h, under what circumstances do we need to call rotateRight(h)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
