Objective: Students will apply concepts of Java Generics and Red-Black Trees in this programming assignment. Assignment...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objective: Students will apply concepts of Java Generics and Red-Black Trees in this programming assignment. Assignment Description: In this class, we have learned a couple of advanced data structures related to trees. In this assignment, you will manage an address book of professors with the abstract data type (ADT) red-black tree data structure. You will create your own Red-Black Trees using Java Generics This programming assignment must be completed in the Java programming language. Any other language used will result in score of 0 on the assignment. For this assignment, you must follow these requirements. 1. You will create an ADT Red-Black Tree class called AddressBookTree with Java Generics (type T and type U). The attribute for the class must contain: a. root of Node b. You may create additional helper attributes that can assist with maintaining the red-black tree. 2. You will use two unique type variables T and U. T represents the name and U represents office. 3. You will create a Node class that will represent the nodes in a red-black tree using generics. The attributes needed for the class are a. Name of type T (Generics) b. Office of type U (Generics) c. Reference to parent node d. Reference to left child node e. Reference to right child node f. An int that represents color (0 for black and 1 for red) 4. The AddressBookTree class must have the following methods. Most of the methods have been provided to you in the pseudocode on the slides. a. Default constructor i. Set everything to default values. b. Insert i. Parameter takes two arguments: T name, U office c. Insert-Fix (applying rules for insertion) i. Parameter takes one argument: Node<T, U> d. Delete i. Parameter takes one argument: T name e. Delete-Fix (applying rules for deletion) i. Parameter takes one argument: Node<T, U> f. Rotations (both left and right) i. Parameter for both takes one argument: Node<T, U> g. RB-Transplant i. Parameter takes two arguments: Node<T, U> and Node<T, U> h. Display (inorder traversal) i. No arguments needed. Note: There is a space between the name and office. i. countBlack-method to count black nodes in tree i. Parameter takes Node to count from (the root) j. countRed-method to count red nodes in tree i. Parameter takes Node to count from (the root) k. You may also create additional helper methods as well. 5. Make all methods public and class attribute private. It's good practice! A runner file (Address BookTreeRunner.java) has been provided for you to show you how the methods are called along with 3 test cases based on maintaining the tree after certain operations. A text file is also provided for you that will help fill the tree in the initial run. The text file itself must be in the same directory as the runner file. What to submit: Submit a file called Address BookTree.java to webcourses. You are not required to submit the runner file as that will be provided for the graders to test your code. Please make sure the runner file provided works for your code. Any name changes may cause your program not to work when graded, which will result in a lower score on the assignment and would not be changed. Important Note for running Eustis: Many of you are probably using IDEs like Netbeans and Eclipse to build your Java Solutions. Please note that some of these IDEs will automatically place your Java file in some sort of package. Please make sure your Java file is not defined in some package as this can result package private errors. Any such error that occurs during the grading will not be fixed and points will be deducted as such in accordance with the respective categories in the rubric. Also, DO NOT create a main method in your solution file!! This will result in your code not running properly with the runner file which will result in points being deducted from the respective categories. Objective: Students will apply concepts of Java Generics and Red-Black Trees in this programming assignment. Assignment Description: In this class, we have learned a couple of advanced data structures related to trees. In this assignment, you will manage an address book of professors with the abstract data type (ADT) red-black tree data structure. You will create your own Red-Black Trees using Java Generics This programming assignment must be completed in the Java programming language. Any other language used will result in score of 0 on the assignment. For this assignment, you must follow these requirements. 1. You will create an ADT Red-Black Tree class called AddressBookTree with Java Generics (type T and type U). The attribute for the class must contain: a. root of Node b. You may create additional helper attributes that can assist with maintaining the red-black tree. 2. You will use two unique type variables T and U. T represents the name and U represents office. 3. You will create a Node class that will represent the nodes in a red-black tree using generics. The attributes needed for the class are a. Name of type T (Generics) b. Office of type U (Generics) c. Reference to parent node d. Reference to left child node e. Reference to right child node f. An int that represents color (0 for black and 1 for red) 4. The AddressBookTree class must have the following methods. Most of the methods have been provided to you in the pseudocode on the slides. a. Default constructor i. Set everything to default values. b. Insert i. Parameter takes two arguments: T name, U office c. Insert-Fix (applying rules for insertion) i. Parameter takes one argument: Node<T, U> d. Delete i. Parameter takes one argument: T name e. Delete-Fix (applying rules for deletion) i. Parameter takes one argument: Node<T, U> f. Rotations (both left and right) i. Parameter for both takes one argument: Node<T, U> g. RB-Transplant i. Parameter takes two arguments: Node<T, U> and Node<T, U> h. Display (inorder traversal) i. No arguments needed. Note: There is a space between the name and office. i. countBlack-method to count black nodes in tree i. Parameter takes Node to count from (the root) j. countRed-method to count red nodes in tree i. Parameter takes Node to count from (the root) k. You may also create additional helper methods as well. 5. Make all methods public and class attribute private. It's good practice! A runner file (Address BookTreeRunner.java) has been provided for you to show you how the methods are called along with 3 test cases based on maintaining the tree after certain operations. A text file is also provided for you that will help fill the tree in the initial run. The text file itself must be in the same directory as the runner file. What to submit: Submit a file called Address BookTree.java to webcourses. You are not required to submit the runner file as that will be provided for the graders to test your code. Please make sure the runner file provided works for your code. Any name changes may cause your program not to work when graded, which will result in a lower score on the assignment and would not be changed. Important Note for running Eustis: Many of you are probably using IDEs like Netbeans and Eclipse to build your Java Solutions. Please note that some of these IDEs will automatically place your Java file in some sort of package. Please make sure your Java file is not defined in some package as this can result package private errors. Any such error that occurs during the grading will not be fixed and points will be deducted as such in accordance with the respective categories in the rubric. Also, DO NOT create a main method in your solution file!! This will result in your code not running properly with the runner file which will result in points being deducted from the respective categories.
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner Class Node class RedBlackNode RedBlackNode left right int element int color Constructor public RedBlackNodeint theElement this theElement null null Constructor public RedBlackNo... View the full answer
Related Book For
Organizational Behavior
ISBN: 978-0273774815
8th Edition
Authors: Andrzej A. Huczynski, David A. Buchanan
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
An experiment consists of observing the eye color and age of all United States citizens. Let E be the event "blue eyes," F the event "at least 18 years old," and G the event "brown eyes and younger...
-
Strassel Investors buys real estate, develops it, and resells it for a profit. Anew property is available, and Bud Strassel, the president and owner of Strassel Investors, believes it can be sold for...
-
As the owner of a landmark Chicago skyscraper, you decide to purchase insurance that will pay $1 billion in the event the building is destroyed by terrorists. Suppose the likelihood of such a loss is...
-
Prepare journal entries to record the following transactions of an Internal Service Fund: 1. Paid salaries of $10,000. Additional salaries accrued but not paid totaled $300. 2. Purchased equipment...
-
(a) The Treasury desk of a global bank incorporated in UK wants to invest GBP 200 million on 1st January, 2019 for a period of 6 months and has the following options: (1) The Equity Trading desk in...
-
A project has a first cost of \($180,000,\) an estimated salvage value of \($20,000\) after 6 years, and other economic attributes as detailed in the table below. Unfortunately, as the end of year 4...
-
Describe how you can use neural networks to make customer targeting decisions?
-
Fewer workers are in traditional, full-time stable jobs while a growing number are in so-called contingent jobs, such as temporary or on-call positions, or are treated as independent...
-
Earnhardt Driving School's 2018 balance sheet showed net fixed assets of $5.4 million, and the 2019 balance sheet showed net fixed assets of $6 million. The company's 2019 income statement showed a...
-
Money is deposited into a fund continuously for 2n years with the amount per year being 2000. The accumulated amount at the end of 2n years is 68934.44616, and the accumulated amount at the end of n...
-
Under fixed-interval lot sizing, order sizes for component parts are determined based on which one of the following? Gross requirements - net requirements for a predetermined number of periods Net...
-
Should technical violations of probation and parole be used as a cause to re-incarcerate someone? Please justify your position and defend your answers with facts/data/research.
-
Question 5 (a) Eighteen months ago, Aishah deposited RM1500 in a savings account earning 5% interest compounded semi-annually. At the same time, she deposited RM150 at the end of every month in...
-
Willingness to pay as a measure of a person's value for a particular good measures the maximum a person would be willing to pay requires that payment actually be made depends on the satisfaction that...
-
Linn Products is mentioned in this chapter as a company that uses job enrichment successfully in the manufacture of its hi-fi products. Their website is www.LinnProducts.net. Linn also has its own...
-
Employees in the Bank Wiring Observation Room were subject to group-devised norms which its members policed and enforced. Think of a group that you have known, e.g. at school, work, college or...
-
Suggest reasons to account for the popularity of the rationalist view of organizations, among managers, management consultants, management academics, and politicians.
-
One growing concern regarding the U.S. economy is the inequality in the distribution of income. The data in Table 1 represent the distribution of household income for various levels of income in...
-
One growing concern regarding the U.S. economy is the inequality in the distribution of income. An economist wants to know if the distribution of income is changing, so she randomly selects 1500...
-
Test whether \(\mu_{1}
Study smarter with the SolutionInn App