Assignment 5
Assignment 5
Assignment-5
Due-date: Friday, March 15, 2024 @11:59pm
Cut-off date: Sunday, March 17, 2024 @11:59pm
Objective:
The objective of this assignment is to build a 2-3 Tree.
Problem Specification:
In this assignment, you will be implementing a 2-3 tree to handle the DVD database of a video store. A 2-3
tree is a tree satisfying the following requirements
All internal nodes in the tree have either two or three children.
All leaves of the tree are at the same level.
In this assignment, TreeNodes will store the titles of the DVDs. The title will be stored as a string and
titles may consist of multiple words. Please download the TwoThreeTreeAssignmentSample before
start. Print the tree in the following manners. When printing a value, print the string followed by a, and
1 space. You must follow these guidelines exactly! For example: Aliens, The Lord of the Rings, Kill Bill,.
Your task is to implement the following methods:
void preOrder(TreeNode<T> treeNode) - Traverse and print the tree in preorder notation following the
printing guidelines specified above.
void inOrder(TreeNode<T> treeNode) - Traverse and print the tree in inorder notation following the
printing guidelines specified above.
void postOrder(TreeNode<T> treeNode) - Traverse and print the tree in postorder notation following
the printing guidelines specified above.
TreeNode<T> retrieveItem(TreeNode<T> treeNode, T searchKey) - Search for a specified item in the
tree.
TreeNode<T> insertItem(TreeNode<T> treeNode, T insertKey) - Insert an item into the 2-3 tree. Be
sure to maintain the 2-3 tree properties.
Your main method should provide prompts to ask user to insert new DVD titles, search for one particular
DVD, and print out all the DVD you have in the database (inorder, preorder, and postorder). Please note
that you will not get any credit if you do not implement generic versions of 2-3 tree operations
with the above-mentioned criteria.
Submission Instructions:
Please note that the submitted work will be considered as your own work and you confirm
that you have not received any unauthorized assistance in preparing for or doing this lab/as-
signment/examination. You confirm knowing that a mark of 0 may be assigned for entire
work.
Submit your complete Java source files (.java). Comment your program carefully so that it can be read
and understood. If your program is not properly commented you may lose marks. See marking scheme
for details.
COSC2007O24W: Assignment-5
Marking Scheme:
You will receive full credits for the working code, otherwise zero. No partial credits!