Cosc 2P03 Fall 2017
Assignment#3
(Due date for assignment is Monday Nov. 6th 4:00
p.m., Late date Thursday Nov. 9th, 4:00 p.m.)
Data Input Below.
Objective
To implement an AVL tree with deletion.
The Assignment
Implement a BST which has a String element and thus represents
the Key as well; add an integer variable C which will represent
the number of occurrences of the element. Your BST should support
the following operations. Insert, Delete and InOrder. Each of the
preceding operations should be implemented recursively where
appropriate. In the event of like elements you are to increment
the count C field.
The BST should support AVL. Thus on every insertion or deletion
you should insure that the tree is AVL complaint. To help support
this, write a method IsAVL() which will return a Boolean if the
tree is or is not AVL.
Load the BST with the supplied data. Print a SOT of this data
(String element and count). As well, run isAVL and print the
result of this.
Rescan the input data and remove ever element from the tree which
starts with a letter between (d - n or D - N inclusive). Print a
SOT and run isAVL as above.
Data Input Above.
The data for this assignment is the text between but not including
the headings Data Input Below
and Data Input Above.
You are to treat each word as case sensitive. You may ignore
punctuation, brackets, white space and hyphens. A word can be a
number. All words are to be trimmed removing leading and trailing
spaces.
Output expected:
- SOT listing of the tree after it has been built, followed by
the result of IsAVL.
- SOT listing of the tree after the elements as described have
been removed, followed by the result of IsAVL
Suggestions
Verify that your algorithms for insert, delete and IsAVL give the
correct results. Use a small test data set that you control. Try
drawing the trees by hand for these small test sets. Once you have
confidence that it works on the small set then graduate to the
larger data set.
Submission Requirements:
- Cover Sheet completely filled out, available
from: "http://www.cosc.brocku.ca/forms/cover"
Note: your assignment will not be marked unless one is submitted
with the assignment on the assignment due date.
- Commented and properly documented source code
listing, use Java Doc style.
- Listing of any input you used to test your program.
- Listing of your output which reflects the input.
- Source code is to be Java.
- Be sure to hand in a hard copy of the above and a soft copy as
directed below.
- Electronic
submission, run the script "submit2p03" from sandcastle.
- Statement on coversheet with following information.
- Platform, e.g. Mac, PC, Commodor 64, my Java enabled wrist
watch.
- Compiler Version, e.g. Java 1.7, Java 1.81 e.g.
Good Luck