Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java, 1. extend the BSTNode class (as below) to form a new class RBNode to add a color field and a value field to

In java,

1. extend the BSTNode class (as below) to form a new class RBNode to add a color field and a value field to each node (let the color field be of type boolean and the value field be a generic type). Also extend the BinarySearchTree class to create the RBTree class and include the following methods.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

2. Implement Left Rotation and Right Rotation methods in the RBNode class. The left-totate algorithm is given below. Following that algorithm, devise the Right-rotate algorithm and implement the methods.

image text in transcribed

3. Implement a method RBInsert(K key, V value) in to insert a node to a Red Black Tree (this method uses the insert method of ; see the algorithm below). In class implement the case for which parent of x is the left child of grandparent of x.

image text in transcribed

image text in transcribed

4. Write a driver program to test the RBTree class. Make sure you use all the methods implemented above.

public class BinaryTree> private BinaryTreeNode root; 1/ the root of the tree private BinaryTreeNode node) root = node; *Moves the cursor to the root. public void toRoot O cursor = root; * Returns the cursor node. *Greturn cursor public BinaryTreeNode getCursor()[ return cursor; * Sets the root to the provided node. * ONLY USE IN THE DELETE ME THOD * @param node public void setRoot (BinaryTreeNode node) root = node; public class BinaryTree> private BinaryTreeNode root; 1/ the root of the tree private BinaryTreeNode node) root = node; *Moves the cursor to the root. public void toRoot O cursor = root; * Returns the cursor node. *Greturn cursor public BinaryTreeNode getCursor()[ return cursor; * Sets the root to the provided node. * ONLY USE IN THE DELETE ME THOD * @param node public void setRoot (BinaryTreeNode node) root = node

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Background on Jamba Juice

Answered: 1 week ago

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago