Student: Rudi Luo
Student number: 413-6437
email: [email protected]
Note: Only the studentDB.java file is modified, and others are the
same. So only this file is to be handed in and transfered.
If you need those files, which don't need to be modified, please
email to me.
Introduction:
This program is designed to create a student database. The database is used to record information about students enrolled in the University of Seely's Bay. The database contain lists of all the courses offered by the university, the students enrolled at the university, and what courses each student is taking.
There are some rules of enrollment:
Question Answering:
1. Which variable in the program represents the
adjacency matrix?
The variables are student Id and course Id. They represents
the adjacency matrix, which is describe if a student enrolled in a course.
2.What are the advantages/disadvantages of the adjacency matrix implementation compared to the implementation from assignment 2? Your answer should make reference to the computational complexity of the load() and check() operations.
Complexity of the two implementation with m students
and n courses
(suppose that the graduate part is omitted in the assitnment2 implementation
and a course have average 5 enrolled students)
Methods: | adjacency matrix | assignment 2 |
Load ( ): | ||
before entryKind | 3+6+2(m+n) = 2m+2n+9 | 3+6+2(m+n) = 2m+2n+9 |
if (entry...ugStudent) | 2+15m | 2+16m |
if (entry...course) | 9+9n | 9+5*16n+2=80n+11 |
after entryKind | 2 | 2+8n |
Check ( ) | ||
Rule 1 | 9+7m | 7+15m |
Rule 2 | 6m(4n+6)+5=24mn+36m+5 | 7+7m |
Rule 3 | 3n(5m+4)+5=15mn+12n+5 | 17n |
Overall | 39mn+60m+23n+41 | 40m+117n+38 |
Order | O(2) | O(1) |
As the computation of the complexities shows, the adjacency is second order
and the assignment2 is first order. If the numbers of courses and students
are small, there is no big difference. If there many students and many
courses, the computation with the method in assignment is much faster.
Therefore, the advantage of the implementation in assignment 2 is that
it is faster, but it's hard to design, at least for me. The implementation
with adjacency matrix is slower, but it is pretty to design and write the
program.
Testing:
The running result for the sample.txt database is:
**
** Loading the sample data base. Each line in the
** data base will be echoed as it is read in.
**
ugStudent Mick Jagger 123
ugStudent Doris Day 124
ugStudent Bob Hope 125
ugStudent Gord Downey 126
ugStudent Thelonius Monk 127
ugStudent B.B. King 128
ugStudent Johnny Lee Hooker 129
ugStudent Edsgar Dijkstra 130
ugStudent Thomas Babbage 131
course cisc121 123 129 130 131
course cisc124 123 456
Student 456 enrolled in course cisc124 does not exist
course math100 123 124 128 129
course psyc100 123 124 127 128 129 130
course hist100 123 128 129 130 131
course econ100 123 128 129 131**
** Checking the sample data base.
**
Student Name: Mick Jagger; Student number: 123 is enrolled in both cisc121 and cisc124.
Student Name: Mick Jagger; Student number: 123 is enrolled in 6 courses
Course cisc124 has only 1 students.