CSE 222/505 – Homework 5

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (2 votes)

SCENARIO:
Q1:
1. Extend BinaryTree class to implement Iterable interface. The iterator
should traverse the binary tree pre-order.
2. Extend BinarySearchTree class from BinaryTree class. BinarySearchTree
class should have an extra iterator method levelOrderIterator which
returns an Iterator that traverses the binary search tree in level order.
Test:
Write your traverse methods such that they print each traversed node to
console. Read integers (separated by sapces) from test.txt file. Create a
BinaryTree and a BinarySearchTree. Traverse your trees.
Q2:
Consider the binary tree representation of a family tree in the book. Extend
BinaryTree class to implement FamilyTree class. Your FamilyTree class should
include the following features:
1. One parameter constructor to build a person’s family. The person should
be at the root.
2. Add a new person in the family tree.
The add method should take three parameters:
 The name of the person to be added
 The name of the person’s father or mother
 The nickname of the person’s father or mother.
The nickname is given as in Arabic culture:
 ibn-Fatih (son/daughter of Fatih) or
 ebu-Fatih (father/mother of Fatih).
So, the name of a son/daughter or the name of the father/mother is given
in nickname format to the method. So, there could be more than one
person with the same name in the family tree. To specify where to insert
the person, the name of his/her mother/father is specified together with
mother’s/father’s nickname. If there are more than one father/mother with
the same name and nickname the insertion cannot be completed. Your
method should throw an exception specifying both person’s mother/father
and daughters/sons.
3. A method to traverse the family tree in pre-order. Note that the pre-order
traversal is not the same as the traversal of the binary tree. You should
override the pre-order traversal method of BinaryTree.
4. Override the iterator method of BinaryTree o that the iterator correctly
traverses the family tree.
Test:
 Read family.txt file which includes a family with a person in each line.
The format of the txt file will be as:
Hasan
Ayşe, Hasan, ebu-Ayşe
Ali, Ayşe, ibn-Hasan
Sema, Hasan, ebu-Ayşe

 Create a FamilyTree.
 Write your traverse method such that prints each traversed node to
console. Traverse your tree.
RESTRICTIONS:
– Write a main class for each of two questions.
– Don’t use any other third part library.
GENERAL RULES:
– For any question firstly use course news forum in moodle, and then the
contact TA.
– You can submit assignment one day late and will be evaluated over twenty
percent (%20).
– Register github student pack and create private project and upload your
projects into github.
– Your appeals are considered over your github project process.
TECHNICAL RULES:
– Use given CSE222-VM to develop and test your homeworks (your code
must be working on CSE222-VM), CSE222-VM download link will be given
on Moodle.
– Implement clean code standarts in your code;
o Classes, methods and variables names must be meaningful and
related with the functionality.
o Your functions and classes must be simple, general, reusable and
focus on one topic.
o Use standart java code name conventions.
REPORT RULES:
– Add all javadoc documentations for classes, methods, variables …etc. All
explanation must be meaningful and understandable.
– You should submit your homework code, javadoc and report to Moodle in a
studentid_hw#.tar.gz file.
– Use the given homework format including selected parts:
Detailed system requirements
The Project usecase diagrams (extra points)
Class diagrams *
Other diagrams
Problem solutions approach *
Test cases
Running command and results
GRADING :
– No error handling : -50
– No javadoc documentation : -50
– No report : -90
– Disobey restrictions : -100
– Cheating : -200
– Your solution is evaluated over 100 as your performance.