COP3503 Computer Science 2
Dr. Andrew Steinberg
Summer 2022
Programming Assignment 2
Address Book Assignment
Due: 7/1/2022 at 11:59pm
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
elated 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
. You may create additional helper attributes that can assist with maintaining the
ed-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)
. 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.
. Insert
i. Parameter takes two arguments: T name, U office
c. Insert-Fix (applying rules for insertion)
i. Parameter takes one argument: Node
d. Delete
i. Parameter takes one argument: T name
e. Delete-Fix (applying rules for deletion)
i. Parameter takes one argument: NodeCOP3503 Computer Science 2
Dr. Andrew Steinberg
Summer 2022
f. Rotations (both left and right)
i. Parameter for both takes one argument: Node
g. RB-Transplant
i. Parameter takes two arguments: Node and Node
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 (AddressBookTreeRunner.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 AddressBookTree.java to webcourses. You are not
equired 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 e
ors. Any such e
or that occurs during the
grading will not be fixed and points will be deducted as such in accordance with the respective
categories in the ru
ic. Also, DO NOT create a main method in your solution file!! This will
esult in your code not running properly with the runner file which will result in points being
deducted from the respective categories.
Tanvir Ahmed ENG1-453
Sarah Angell HEC-230
Reza Aria HEC-258
Matthew Ge
er HEC-257
Andrew Steinberg HEC-341
Sean Szumlanski HEC-219
Arup Guha HEC-240
Tom Holland HEC-003D
Richard Leinecker HEC-357
Mark LLewellyn HEC-236
Travis Meade HEC-328
Euripides Montagne HEC-216
Thomas Nedorost HEC-317
Karin Markle HEC-412
Yanjie Fu HPA2-238
Paul Gazzillo HEC-239
Johnathan Mell HPA2-238G
Yogesh Singh Rawat HEC-241
Sharma Thankachan HEC-207
Scarlett Johansson HEC-004
Delores Um
idge HEC-108D
Wei Zhang BIO-137B
Damian Dechev HEC-221
Ryan Reynolds HEC-002C
Mark Heinrich HEC-345
Haiyan Hu HEC-233
Fei Liu HEC-217
Niels da Vitoria Lobo HEC-252
Jennifer Lawrence HEC-001B
Abhijit Mahalanobis HEC-244
Ryan McMahan HEC-433
David Mohaisen HPA2-240
Sumanta Pattanaik HEC-437E
Dirk Reiners HEC-220
Liqiang Wang HEC-437E
Melisa Mccarthy HEC-112
Pamela Wisniewski HEC-217A
Annie Wu HEC-314
Cliff Zou HEC-243
Ladislau Boloni HEC-319
Carolina Cruz-Neira HEC-214
Hassan Foroosh HEC-212
Chris Pratt HEC-123G
Kien Hua HEC-229
Charles Hughes HEC-247C
Joseph LaViola II HEC-321
Gary T. Leavens HEC-329
Dan Marinescu HEC-304
Mubarak Shah HEC-245D
Johnny Depp HEC-001A
Yan Solihin HPA2-239
Gita Sukthankar HEC-232
Damla Turgut HEC-316
Shibu Yooseph BIO-133A
Shaojie Zhang HEC-311
Amy Poehler HEC-300
*************************************************
Beginning Test Cases...
Test Case 1...
Testing the initial setup...
Abhijit Mahalanobis HEC-244
Amy Poehler HEC-300
Andrew Steinberg HEC-341
Annie Wu HEC-314
Arup Guha HEC-240
Carolina Cruz-Neira HEC-214
Charles Hughes HEC-247C
Chris Pratt HEC-123G
Cliff Zou HEC-243
Damian Dechev HEC-221
Damla Turgut HEC-316
Dan Marinescu HEC-304
David Mohaisen HPA2-240
Delores Um
idge HEC-108D
Dirk Reiners HEC-220
Euripides Montagne HEC-216
Fei Liu HEC-217
Gary T. Leavens HEC-329
Gita Sukthankar HEC-232
Haiyan Hu HEC-233
Hassan Foroosh HEC-212
Jennifer Lawrence HEC-001B
Johnathan Mell HPA2-238G
Johnny Depp HEC-001A
Joseph LaViola II HEC-321
Karin Markle HEC-412
Kien Hua HEC-229
Ladislau Boloni HEC-319
Liqiang Wang HEC-437E
Mark Heinrich HEC-345
Mark LLewellyn HEC-236
Matthew Ge
er HEC-257
Melisa Mccarthy HEC-112
Mubarak Shah HEC-245D
Niels da Vitoria Lobo HEC-252
Pamela Wisniewski HEC-217A
Paul Gazzillo HEC-239
Reza Aria HEC-258
Richard Leinecker HEC-357
Ryan McMahan HEC-433
Ryan Reynolds HEC-002C
Sarah Angell HEC-230
Scarlett Johansson HEC-004
Sean Szumlanski HEC-219
Shaojie Zhang HEC-311
Sharma Thankachan HEC-207
Shibu Yooseph BIO-133A
Sumanta Pattanaik HEC-437E
Tanvir Ahmed ENG1-453
Thomas Nedorost HEC-317
Tom Holland HEC-003D
Travis Meade HEC-328
Wei Zhang BIO-137B
Yan Solihin HPA2-239
Yanjie Fu HPA2-238
Yogesh Singh Rawat HEC-241
TEST 1 Passed!
*************************************************
Test Case 2...
Testing the insert method...
Inserting some items...
TEST 2 Passed!
*************************************************
*************************************************
Test Case 3...
Testing the deletion method...
Removing some items...
TEST 3 Passed!
Ending Test Cases...
*************************************************
Abhijit Mahalanobis HEC-244
Andrew Steinberg HEC-341
Annie Wu HEC-314
Arup Guha HEC-240
Carolina Cruz-Neira HEC-214
Charles Hughes HEC-247C
Cliff Zou HEC-243
Damian Dechev HEC-221
Damla Turgut HEC-316
Dan Marinescu HEC-304
David Mohaisen HPA2-240
Dirk Reiners HEC-220
Euripides Montagne HEC-216
Fei Liu HEC-217
Gary T. Leavens HEC-329
Gita Sukthankar HEC-232
Haiyan Hu HEC-233
Hassan Foroosh HEC-212
Johnathan Mell HPA2-238G
Joseph LaViola II HEC-321
Karin Markle HEC-412
Kien Hua HEC-229
Ladislau Boloni HEC-319
Liqiang Wang HEC-437E
Mark Heinrich HEC-345
Mark LLewellyn HEC-236
Matthew Ge
er HEC-257
Mubarak Shah HEC-245D
Niels da Vitoria Lobo HEC-252
Pamela Wisniewski HEC-217A
Paul Gazzillo HEC-239
Reza Aria HEC-258
Richard Leinecker HEC-357
Ryan McMahan HEC-433
Sarah Angell HEC-230
Sean Szumlanski HEC-219
Shaojie Zhang HEC-311
Sharma Thankachan HEC-207
Shibu Yooseph BIO-133A
Sumanta Pattanaik HEC-437E
Tanvir Ahmed ENG1-453
Thomas Nedorost HEC-317
Travis Meade HEC-328
Wei Zhang BIO-137B
Yan Solihin HPA2-239
Yanjie Fu HPA2-238
Yogesh Singh Rawat HEC-241
*************************************************
Yay! All test cases passed!