Question: Please code in C + + . I need help on coding an ExtendedRBTNode.h file and an ExtendedRedBlackTree.h file. Thank you 8 . 1 2

Please code in C++. I need help on coding an ExtendedRBTNode.h file and an ExtendedRedBlackTree.h file. Thank you 8.12 LAB: Red-black tree Nth largest operation Step 1: Inspe tep 5: Run tests in develop mode and submit mode Then Deter |us acr (x)Sis ,=-1=(n)-1 in ,(cters talese} return false; // not case 6 protected: virtual void InsertNode(BSTNode* node) override BinarySearchTree: insertion starts with the standard BST insertion // Color the node red, then balance ((RBTNode .^*) node )->color = RBTNode : : REDCOLOR; InsertionBalance ((RBTNode*)node ); virtual BSTNode* MakeNewNode(int key) override { return new RBTNode(key); virtual bool RemoveNode(BSTNode* bstNode) override { if (lbstNode){} RBTNode* node =(RBTNode ) bstNode; if (node->GetLeft() && node->GetRight()) f RBTNode* predecessorNode -(RBTNode*) node->GetLeft(); while (predecessorNode->GetRight ()) predecessorNode =(. RBTNode .^*) predect }- predecessorNode =(RBTNode ) predecessorNode->etRight () ; // Get predecessor's key, then recursively remove the predecessor node int predecessorKey = predecessorNode->GetKey () Remove // Assign the node's key with the now-removed predecessor node's key return true if (node->IsBlack ()){ PrepareForRemoval (node); BinarySearchTree: : RemoveNode(node)// One special case if the root was changed to red RBTNode ^8 rootNode =(RBTNode*) GetRoot() if ( rootNode && rootNode->IsRed ()) rootNode->Color = RBTNode: : BLACKCOLOR root return true; public: RedBlackTree ()// Note: Parent class's constructor does all needed work void InsertionBalance(RBTNode* node) If If node is the tree's root, then color node black and return node->COlor = RBTNode: : BLACKCOLOR: return; // Pointer to parent node is needed for remaining operations RBTNode* parent =(RBTNode*) node->GetParent 0// If parent is black, then return without any changes return; }// pointers tograndparent and uncle are needed for remaining operations RBTNode ^8 grandparent = node->GetGrandparent () ; RBTNode* uncle - node->Getuncle(); // If parent and uncle are both red, then color parent and uncle black, if (uncle && uncle->IsRed ())[ parent->color = uncle->color = RBTNOde : : BLACKCOLOR; grandparent >COlor = RBTNode: : REDCOLOR: return; // If node is parent's right child and parent is grandparent's left child, then rotate left at parent, update node and parent to point to if (node == parent->GetRight () && parent == grandparent->GetLeft ()). Rotateleft (parent) node = parent ; parent =(. RBTNode .^*) node->GetParent ()// Else if node is parent's left child and parent is grandparent's right // child, then rotate right at parent, update node and parent to point to l/ parent and grandparent, respectively RotateRight (parent) node = parent 3. parent =(RBTNode ^*) node->GetParent () ; // Color parent black and grandparent red parent >COlor = RBTNOde:: BLACKCOLOR; // If node is parent's Left child, then rotate right at grandparent, If otherwise rotate Left at grandparent RotateRight(grandparent) else el RotateLeft (grandparent): 3 bool IsNullorBlack(RBTNode* node) if (node == nullptr) return node->IsBlack () ; bool IsNotNullandRed(RBTNode* node) if (node == nullptr) return false; return node > Is Red();Current file: BSTNodeVisitor.h

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 Programming Questions!