2020/7/27 COMP9024 20T2 – Assignment
COMP9024 20T2 Assignment Data Structures and Algorithms
goNSW
Change Log
We may make minor changes to the spec to address/clarify some outstanding issues. These may require minimal changes in your design/code, if at all. Students are strongly encouraged to check the change log regularly.
Version 1: Released on 10 July 2020
Objectives
The assignment aims to give you more independent, self-directed practice with
advanced data structures, especially graphs graph algorithms
asymptotic runtime analysis
Admin
Marks 3 marks for stage 1 (correctness) 5 marks for stage 2 (correctness) 2 marks for stage 3 (correctness)
1 marks for complexity analysis 1 mark for style ———————
Total: 12 marks
Due 11:00:00am on Monday 3 August (week 10) Late 2 marks (16.67%) off the ceiling per day late
(e.g. if you are 25 hours late, your maximum possible mark is 8)
Aim
Your task is to write a program goNSW.c for finding an optimal public transport connection that takes into account a given departure time and user preferences.
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
1/10
2020/7/27 COMP9024 20T2 – Assignment
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
2/10
Input
Network
Your program should start by prompting the user to input a positive number n followed by n lines, each containing the name of a train station or bus/light rail stop. An example is:
prompt$
Enter the total number of stops on the network:
You may assume that:
The input is syntactically correct.
Names require no more than 31 characters and will not use any spaces. No stop name will be input more than once.
Hint:
To read a single line with a stop name you may use:
Schedules
Next, your program should ask the user for the number m of busses, trains and light rail vehicles running during a day, followed by m schedules. Each schedule requires the number of stops, k≥2, followed by k*2 lines of the form:
meaning that passengers can get on or off at that time (hh – hour, mm – minute) at that stop. An example is:
Enter the number of schedules: Enter the number of stops:
scanf(“%s”, stop); // stop is a character array (= string variable)
hhmm stop-name
5
5 2
WSNog/.
draynyW WSNU notgnisneK lartneC nwotanihC
0461
2020
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php 3/10
/7/27 COMP9024 20T2 – Assignment
Enter the number of stops:
You may assume that:
The input is syntactically correct: 4 digits, then a new line with the name of a stop.
All times are valid and range from 0000 to 2359.
Stops are input in the right (temporal) order.
There are no overnight connections: Each bus, light rail or train will reach its final stop before midnight. Only valid stops that have been input before will be used.
Queries
After reading the transportation network, your program should prompt the user to search for a connection:
From:
To:
Depart at:
Again you may assume that the input is correct:
Only stops that have been entered before are used and a valid time is given. The two stops will not be the same.
If the user inputs “done,” then your program should terminate:
From:
Thank you for using goNSW.
2
enod
0361 draynyW
WSNU
lartneC 0071 WSNU 5461
draynyW 5171 nwotanihC 8071 lartneC 5071 notgnisneK 5461 WSNU
2020
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
/7/27 COMP9024 20T2 – Assignment
4/10
prompt$
Stage 1 (3 marks)
For stage 1, you should demonstrate that you can read the input and generate a suitable data structure. For this stage, all test cases will only use queries (From, To, DepartAt) for which
there is only one bus, train or light rail service connecting From and To ; and this is guaranteed to depart on, or after, the requested time, DepartAt .
Hence, all you need to do for this stage is find and output this direct connection, including all stops along the way and the arrival/departure times. Here is an example to show the desired behaviour of your program for a stage 1 test:
prompt$
Enter the total number of stops on the network:
Enter the number of schedules: Enter the number of stops:
Enter the number of stops:
7
5 2
2
WSNog/.
ebelG 8151 yawdaorB 9541
7201 notgnisneK 2201 lartneC 0001 BVQ 0590 draynyW 5490
yawdaorB ebelG WSNU notgnisneK lartneC BVQ draynyW
WSNU
2020
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php 5/10
/7/27 COMP9024 20T2 – Assignment
From:
To:
Depart at:
1459 Broadway 1518 Glebe
From:
To:
Depart at:
0950 QVB
1000 Central 1022 Kensington
From:
Thank you for using goNSW. prompt$
Stage 2 (5 marks)
For stage 2, you should extend your program for stage 1 such that it always finds, and outputs, a connection between From and To that departs on, or after, the requested time DepartAt ; and
arrives as early as possible. You should assume that:
Changing takes no time: Passengers arriving at a stop can get onto any other train, bus or light rail service that leaves that stop at the same time or later.
In all test scenarios there will be at most one connection that satisfies all requirements.
If there is no connection, the output should be:
Here is an example to show the desired behaviour and output of your program for a stage 2 test:
No connection found.
enod
0590 notgnisneK
0590
ebelG
yawdaorB
BVQ
2020/7/27 COMP9024 20T2 – Assignment
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
6/10
prompt$
Enter
Enter Enter
the total number of stops on the network:
the number of schedules: the number of stops:
Enter
the number of stops:
From:
To:
Depart at:
0915 Eastwood 0935 Strathfield 1002 Redfern Change at Redfern 1005 Redfern
1010 Central
1015 Wynyard
From:
To:
Depart at:
5
4 2
3
0290 nrefdeR
doowtsaE
0190 draynyW
doowtsaE
WSNog/.
draynyW 5101 lartneC 0101 nrefdeR 5001
draynyW 7101 nrefdeR 2001 dleifhtartS 5390 doowtsaE 5190
draynyW dleifhtartS nrefdeR doowtsaE lartneC
2020
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
/7/27 COMP9024 20T2 – Assignment
7/10
No connection found.
From:
Thank you for using goNSW.
Stage 3 (2 marks)
For stage 3, you should extend your program for stage 2 such that:
If there are two or more valid connections with the same earliest arrival time, choose the one with the latest departure time. Here is an example to show the desired behaviour and output of your program for a stage 3 test:
prompt$
Enter
Enter Enter
the total number of stops on the network:
the number of schedules: the number of stops:
Enter
From: To:
the number of stops:
5
5 2
2
WSNog/.
draynyW WSNU
lartneC 0071 WSNU 5461
draynyW 5171 nwotanihC 8071 lartneC 5071 notgnisneK 5461 WSNU 0461
draynyW WSNU notgnisneK lartneC nwotanihC
enod
2020
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php 8/10
/7/27 COMP9024 20T2 – Assignment
Depart at:
1645 UNSW
1700 Central Change at Central 1705 Central
1708 Chinatown 1715 Wynyard
From:
Thank you for using goNSW.
Complexity Analysis (1 mark)
Your program should include a time complexity analysis for the worst-case asymptotic running time of your program, in Big-Oh notation, depending on the size of the input:
1. the number of stops, n
2. the number of schedules, m
3. the maximum number k of stops on a single train, bus or light rail line.
Hints
If you find any of the following ADTs from the lectures useful, then you can, and indeed are encouraged to, use them with your program:
linked list ADT : list.h, list.c
stack ADT : stack.h, stack.c
queue ADT : queue.h, queue.c
priority queue ADT : PQueue.h, PQueue.c graph ADT : Graph.h, Graph.c
weighted graph ADT : WGraph.h, WGraph.c
You are free to modify any of the six ADTs for the purpose of the assignment (but without changing the file names). If your program is using one or
more of these ADTs, you should submit both the header and implementation file, even if you have not changed them.
Your main program file goNSW.c should start with a comment: /* … */ that contains the time complexity of your program in Big-Oh notation, together with a short explanation.
0361
enod
2020/7/27 COMP9024 20T2 – Assignment
Testing
We have created a script that can automatically test your program. To run this test you can execute the dryrun program that corresponds to this assignment. It expects to find, in the current directory, the program goNSW.c and any of the admissible ADTs ( ) that your program is using, even if you use them unchanged. You can use dryrun as follows:
prompt$
Please note: Passing dryrun does not guarantee that your program is correct. You should thoroughly test your program with your own test cases.
Submit
For this project you will need to submit a file named goNSW.c and, optionally, any of the ADTs named Graph,WGraph,stack,queue,PQueue,list that your program is using, even if you have not changed them. You can either submit through WebCMS3 or use a command line. For example, if your program uses the Graph ADT and the queue ADT, then you should submit:
prompt$
Do not forget to add the time complexity to your main source code file goNSW.c.
You can submit as many times as you like — later submissions will overwrite earlier ones. You can check that your submission has been received on
WebCMS3 or by using the following command:
prompt$
Marking
This project will be marked on functionality in the first instance, so it is very important that the output of your program be exactly correct as shown in the examples above. Submissions which score very low on the automarking will be looked at by a human and may receive a few marks, provided the code is well-structured and commented.
Programs that generate compilation errors will receive a very low mark, no matter what other virtues they may have. In general, a program that attempts a substantial part of the job and does that part correctly will receive more marks than one attempting to do the entire job but with many errors.
Style considerations include:
Readability
Structured programming Good commenting
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
9/10
tsil,eueuQP,eueuq,kcats,hparGW,hparG
c.eueuq h.eueuq c.hparG h.hparG c.WSNog nssa 4209sc evig
nssa kcehc- nurssalc 4209
WSNog nuryrd 4209
2020/7/27 COMP9024 20T2 – Assignment
Plagiarism
Group submissions will not be allowed. Your program must be entirely your own work. Plagiarism detection software will be used to compare all submissions pairwise (including submissions for similar projects in previous years, if applicable) and serious penalties will be applied, including an entry on UNSW’s plagiarism register.
Do not copy ideas or code from others
Do not use a publicly accessible repository or allow anyone to see your code, not even after the deadline
Please refer to the on-line sources to help you understand what plagiarism is and how it is dealt with at UNSW:
Plagiarism and Academic Integrity UNSW Plagiarism Policy Statement UNSW Plagiarism Procedure
Help
See FAQ for some additional hints.
Finally …
Have fun! Michael
Reproducing, publishing, posting, distributing or translating this assignment is an infringement of copyright and will be referred to UNSW Conduct and Integrity for action.
https://cgi.cse.unsw.edu.au/~cs9024/20T2/assn/index.php
10/10