Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The assignment is to design and implement a program that computes the percentage of red nodes in a given red-black tree (not counting external nodes).
The assignment is to design and implement a program that computes the percentage of red nodes in a given red-black tree (not counting external nodes). You will test your program by running at least 100 10,10 Input: A random sequence of n distinct integers. Output: The percentage of red nodes after inserting all n integers into a red-black tree in the given order. You will accomplish this by using the textbook's RedBlackBST java class as a template. You will only need the code for the Node class, and the put(), isRed). flipColors(), rotateLeft(), and rotateRight0 methods (the delete) methods are not needed.) Your task is to add to this a method called percentRed() which returns the percentage of red nodes in the red-black tree as an integer between 0 and 100. How this is accomplished is up to you. You may alter the other methods as needed to accomplish this goal. Keep in mind, the more efficient your percentRed) code is at doing this the better You will also need to add a main() method, which should do one of two things: . If one exists, read the contents of a text ile provided on the command line for example C:1> java RedBlackBST test file.txt for correctness testing by the marker 2. Else. generate your own sequences to accomplish your experiments for the different values of n given above
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started