Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I need this in C++ code please. A Red-Black Tree is a kind of self-balancing binary search tree. Each node of the binary tree

Hi I need this in C++ code please.

image text in transcribedimage text in transcribed

A Red-Black Tree is a kind of self-balancing binary search tree. Each node of the binary tree has an extra bit, and that bit is often interpreted as the color (red or black) of the node. These color bits are used to ensure the tree remains approximately balanced during insertions and deletions In this task, you are required to develop a Generic Red Black Tree using C++ with the following specifications and functions: - The tree must use C++ templates to accept any data type - The tree will contain unique values only - The tree class will contain the following functions as public functions: o void insert(T value) // inserts a new value into the tree while keeping it balance void getHeight ()// returns the maximum height of the tree T uncle( T value) // returns the uncle of a given node that contains a certain value bool isBalanced(T node) // returns true if the given subtree is balanced bool search(T value) // returns true if a given value exists and prints the path to reach that node void print 0 // displays a visual readable print of the tree nodes including colors void printVerticalSum()// prints the sum of each column of the tree (see next figure) You can add any other functions that will assist you with completing the implementation of the previous functions in the private section of the class Implement the main function of the program to show a menu to the user that allows him to choose an action to perform and takes the necessary input from him. After performing the action, the user will be shown the same menu again. Example for the menu: Please choose an action to continue: 1. Insert value // user inputs a value (1) 2. Display height // the height is displayed (0.5) 3. Display uncle of value // user inputs a value (0.5) 4. Check if subtree is balanced // user inputs the root value of the subtree (1) 5. Search for value // user inputs value (0.5) 6. Print tree (0.5) 7. Print vertical sum (1)

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions