Question: 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 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

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