Example Report
Hi everybody,
I've copied an example of the program test report for assignment 12 (our last assignment) below. Some of you had trouble getting your programs to work well. Please have a look at the output of this assignment. Please also let me know if you need an example implementation.
Here I'm going to list out the test cases and the expected outputs.
-
Case 1: I added two entries named after "stf" and "oal". I also tested "remove" and "find" functionalities in this test.
In this case, no collision was generated. I expected to see two items in the list.
-
Case2: I added two entries named after "usk" and "glt".
In this case, the hash table needed to resize from 3 to 7 when "glt" was added. I expected to see two items in the list.
-
Case3: I added two entries named after "ban" and "mij".
In this case, the hash table needed to resize from 3 to 31 when "mij" was added. I expected to see two items in the list.
-
Case 4: I added three entries named after "stf", "oal", and "qap".
The hash code of "stf" is: 114213; "stf" % 3 = 0; "stf" % 7 = 1
The hash code of "oal" is: 109786; "oal" % 3 = 1; "oal" % 7 = 5
The hash code of "qap" is: 111712; "qap" % 3 = 1; "qap" % 7 = 6
In this case, the hash table needed to resize from 3 to 7 when "qap" was added. The original entries were rehashed into the new table, during which no collision was generated. I expected to see three items in the list.
-
Case 5: I added four entries named after "hpk", "dha", "nrp", and "etz".
The hash code of "hpk" is: 103523; "hpk" % 3 = 2; "hpk" % 7 = 0; "hpk" % 15 = 8
The hash code of "dha" is: 99421; "dha" % 3 = 1; "dha" % 7 = 0; "dha" % 15 = 1
The hash code of "nrp" is: 109356; "nrp" % 3 = 0; "nrp" % 7 = 2; "nrp" % 15 = 6
The hash code of "etz" is: 100779; "etz" % 3 = 0; "etz" % 7 = 0; "etz" % 15 = 9
In this case, the hash table needed to resize from 3 to 7 when "etz" was added. The original entries were rehashed into the new table, during which a new collision was generated. Therefore, the table was resized again to size 15. I expected to see four items in the list.
-
Case 6: I added two entries named after "2<" and "0z".
In this case, no matter how many times the hash table was resized, these two entries can"t exist in the same table because the hash codes are the same. I expected the programto crash with a heap overflow, OutOfMemoryError, unless you handled this case.
-
Case7, 8 (and 9): I also tested the standard user input error handling, removing and finding a person that was not in the list.
Several implementations added both of the two entries in Case 6 into the hash table. Even if the programs passed all of the previous tests, I had to deduct points because the re-hashing procedure didn"t really happen as intended.
If you submitted your assignment 12, you will soon receive an email from me with your report and score. If you haven't received the email by tomorrow, let me know. Also let me know if you have any questions regarding your score.
It has been a great time working as the TA for this class, and I'm glad to have gotten to know some of you. Maybe we'll work together again sometime in the future! I wish every body good luck in the finals and have a great holiday :-)
Cheers!
Jade
Here is your score for Assignment 12.
Score: TDB%
Let me know if you have any questions regarding your score. And let me know if you want a copy of an example implementation for the assignment.
Regards,
Jade
Grading Guildelines
Test Results
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: stf
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "stf" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: oal
Please enter phone number: 234
Warning: "234" does not look like a valid phone number.
Inserted "oal" with phone number "234".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 stf 123
2 oal 234
The current table size is: 3
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: oal
oal"s phone number is 234.
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: delete
Please enter the name to remove: oal
Removed "oal" from the phone book.
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 stf 123
The current table size is: 3
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: usk
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "usk" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: glt
Please enter phone number: 234
Warning: "234" does not look like a valid phone number.
Inserted "glt" with phone number "234".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 usk 123
2 glt 234
The current table size is: 7
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: ban
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "ban" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: mij
Please enter phone number: 234
Warning: "234" does not look like a valid phone number.
Inserted "mij" with phone number "234".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 mij 234
2 ban 123
The current table size is: 31
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: stf
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "stf" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: oal
Please enter phone number: 234
Warning: "234" does not look like a valid phone number.
Inserted "oal" with phone number "234".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: qap
Please enter phone number: 345
Warning: "345" does not look like a valid phone number.
Inserted "qap" with phone number "345".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 stf 123
2 oal 234
3 qap 345
The current table size is: 7
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: hpk
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "hpk" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: dha
Please enter phone number: 234
Warning: "234" does not look like a valid phone number.
Inserted "dha" with phone number "234".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: nrp
Please enter phone number: 345
Warning: "345" does not look like a valid phone number.
Inserted "nrp" with phone number "345".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: etz
Please enter phone number: 456
Warning: "456" does not look like a valid phone number.
Inserted "etz" with phone number "456".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 dha 234
2 nrp 345
3 hpk 123
4 etz 456
The current table size is: 15
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: 2<
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "2<" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: 0z
Please enter phone number: 234
Warning: "234" does not look like a valid phone number.
Error: Cannot add "0z" because another entry with a
different name exists in the hash table and produces the
same hash code.
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 2< 123
The current table size is: 3
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option:
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: insert
Please enter the name to add: cheng
Please enter phone number: 123
Warning: "123" does not look like a valid phone number.
Inserted "cheng" with phone number "123".
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: jade
The name "jade" does not exist.
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: delete
Please enter the name to remove: jade
The name "jade" does not exist.
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: display
# Name Phone Number
1 cheng 123
The current table size is: 3
Choose one of the four options:
1) Type "quit" to exit the program.
2) Type "insert" to add a new contact.
3) Type "delete" to delete a contact.
4) Type "display" to show the phone book.
5) Type a name to show a phone number.
Your option: quit