1. Homepage
  2. Programming
  3. COMP9024 Data Structures and Algorithms - Assignment 2: TripView

COMP9024 Data Structures and Algorithms - Assignment 2: TripView

Engage in a Conversation
UNSWCOMP9024Data Structures and AlgorithmsTripViewC

COMP9024 23T3 CourseNana.COM

Change Log CourseNana.COM

Assignment TripView CourseNana.COM

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. CourseNana.COM

Version 1: Released on 20 October 2023 CourseNana.COM

Objectives CourseNana.COM

The assignment aims to give you more independent, self-directed practice with CourseNana.COM

advanced data structures, especially graphs graph algorithms
asymptotic runtime analysis CourseNana.COM

Admin CourseNana.COM

Marks 3 marks for stage 1 (correctness) CourseNana.COM

5 marks for stage 2 (correctness)
2 marks for stage 3 (correctness)
CourseNana.COM

1 mark for complexity analysis
1 mark for style ———————
CourseNana.COM

Total: 12 marks CourseNana.COM

5:00:00pm on Monday 13 November (week 10) CourseNana.COM

Late 5% penalty per day late (e.g. if you are 25 hours CourseNana.COM

late, your mark will be reduced by 10%) CourseNana.COM

The objective is to write a program tripView.c that generates an optimal trip on (a part of) Sydney's railway network based on user preferences. CourseNana.COM

Input Railway stations CourseNana.COM

The first input to your program consists of an integer n > 0, indicating the number of railway stations on the network, followed by n*2 lines of the form: CourseNana.COM

railway-station transfer-time CourseNana.COM

where the first line is the name of a station and the second line denotes the time – in minutes – it takes to transfer to a different train at that station. CourseNana.COM

Here is an example: CourseNana.COM

./tripView CourseNana.COM

Size of network: 3HarrisPark 1
TownHall
3
CourseNana.COM

NorthSydney 2 CourseNana.COM

You may assume that: CourseNana.COM

The input is syntactically correct.
The maximum length (strlen()) of the name of a railway station is 16 and will not use any spaces.
The transfer time will be a positive integer.
No name will be input more than once. CourseNana.COM

Hint: CourseNana.COM

To read a single line with a station name you should use: CourseNana.COM

scanf("%s", name);
where name is a string, i.e. an array of chars.
CourseNana.COM

Timetables CourseNana.COM

The next input to your program is an integer m > 0, indicating the number of trains on any day, followed by m timetables. Each timetable starts with the number s > 1 of stops followed by s*2 lines of the form: CourseNana.COM

station hhmm CourseNana.COM

meaning that you can get on or off the train at that station at the given time (hh – hour, mm – minute). CourseNana.COM

Here is an example:
Number of timetables:
2 Number of stops: 3HarrisPark 0945
TownHall
1020
NorthSydney
1035
Number of stops: 2TownHall 1024
NorthSydney
1033
CourseNana.COM

You may assume that: CourseNana.COM

The input is syntactically correct.
All times are given as 4 digits and are valid, ranging from 0000 to 2359.
Only train stations that have been input earlier as part of the network will be used.
The stops are input in the correct temporal order.
Each stop will be visited at most once in a single timetable.
All trains reach their final stop before midnight. CourseNana.COM

Trip View CourseNana.COM

The final input to your program are user queries: CourseNana.COM

From: HarrisPark
To: NorthSydney
Arrive at or before: 1200 CourseNana.COM

As before, you may assume that the input is correct: Two different valid railway stations followed by a valid time in the form of 4 digits. CourseNana.COM

Your program should terminate when the user enters "done" when prompted with From: CourseNana.COM

From: done Bye CourseNana.COM

Stage 1 (3 marks) CourseNana.COM

Stage 1 requires you to generate a suitable data structure from the input. Test cases for this stage will only use queries FromStation, ToStation, CourseNana.COM

ArrivalTime such that: CourseNana.COM

there exists one, and only one, train that travels
from
FromStation to ToStation ;
this train arrives on, or before, the given ArrivalTime ; and this train is the desired output for the query. CourseNana.COM

Therefore, at this stage all you need to do is find and output the connection between the two train stations, including all the stops along the way and the arrival/departure times. CourseNana.COM

Here is an example to demonstrate the expected behaviour of your program for a stage 1 test: CourseNana.COM

./tripView CourseNana.COM

Size of network: 7Ashfield 5
Central
8
CourseNana.COM

HarrisPark 1 MilsonsPoint 2 NorthSydney 2 CourseNana.COM

Redfern
5 TownHall 3
CourseNana.COM

Number of timetables: 2 Number of stops: 5HarrisPark 0945
Ashfield
0955
Redfern
1006
TownHall
1020
NorthSydney
1035
Number of stops: 4Redfern CourseNana.COM

1359
Central
1406 TownHall 1410 MilsonsPoint 1430
CourseNana.COM

From: Central
To: MilsonsPoint
Arrive at or before: 1600 CourseNana.COM

1406 Central
1410 TownHall 1430 MilsonsPoint
CourseNana.COM

From: Ashfield
To: NorthSydney
Arrive at or before: 1040 CourseNana.COM

0955 Ashfield 1006 Redfern
1020 TownHall 1035 NorthSydney
CourseNana.COM

From: done Bye CourseNana.COM

Stage 2 (5 marks) CourseNana.COM

For the next stage, your program should find and output a connection from FromStation to ToStation that: CourseNana.COM

may involve one or more train changes;
arrives at ToStation no later than ArrivalTime ; and leaves as late as possible. CourseNana.COM

Note that you can get onto a different train at any station, but it is necessary to take into account the time it takes to change trains at that station. CourseNana.COM

In all test scenarios for this stage there will be at most one connection that satisfies all requirements. CourseNana.COM

Here is an example to demonstrate the expected behaviour of your program for stage 2: CourseNana.COM

./tripView CourseNana.COM

Size of network: 6Ashfield 5
Central
8
CourseNana.COM

HarrisPark 1 NorthSydney 2 CourseNana.COM

Redfern
5 TownHall 3
CourseNana.COM

Number of timetables: 2 Number of stops: 5HarrisPark 0945
Ashfield
0955
Redfern
1006
TownHall
1020
NorthSydney
1035
Number of stops: 3HarrisPark 0950
Central
1010
TownHall
1017
CourseNana.COM

From: HarrisPark
To: NorthSydney
Arrive at or before: 1040 CourseNana.COM

0950 HarrisPark
1010 Central
1017 TownHall Change at TownHall 1020 TownHall
CourseNana.COM

1035 NorthSydney CourseNana.COM

From: done
Bye
If there is no connection that satisfies the requirements, then the output should be: No connection.
From:
HarrisPark
To: TownHall
Arrive at or before: 1015 CourseNana.COM

No connection. CourseNana.COM

Stage 3 (2 marks) CourseNana.COM

For the final stage, if there are multiple possible connections with the same latest departure time, your program should take into account the additional user preference that: CourseNana.COM

among all the connections with the latest possible departure time, choose the one with the shortest overall travel time. CourseNana.COM

You may assume that there will never be more than one connection with the latest possible departure time and the shortest overall travel time. Note also that travel time includes the time it takes to change trains and the waiting time if applicable. CourseNana.COM

Here is an example to demonstrate the expected behaviour of your program for stage 3: CourseNana.COM

./tripView CourseNana.COM

Size of network: 3HarrisPark 1
NorthSydney
2
CourseNana.COM

TownHall
3
Number of timetables: 2 Number of stops: 3HarrisPark 0945
TownHall
1020
NorthSydney
1035
Number of stops: 2TownHall 1024
NorthSydney
1033
CourseNana.COM

From: HarrisPark
To: NorthSydney
Arrive at or before: 1040 CourseNana.COM

0945 HarrisPark
1020 TownHall Change at TownHall 1024 TownHall
CourseNana.COM

1033 NorthSydney CourseNana.COM

From: done Bye CourseNana.COM

Complexity Analysis (1 mark) CourseNana.COM

You should include a time complexity analysis for the asymptotic worst-case running time of your program, in Big-Oh notation, depending on the size of the input: CourseNana.COM

  1. the size of the network, n CourseNana.COM

  2. the number of timetables, m CourseNana.COM

  3. the maximum number of stops on any one timetable, s. CourseNana.COM

Hints CourseNana.COM

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: CourseNana.COM

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 CourseNana.COM

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. CourseNana.COM

Your main program file tripView.c should start with a comment: /* ... */ that contains the time complexity of your program in Big-Oh notation, together with a short explanation. CourseNana.COM

Testing CourseNana.COM

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 tripView.c and any of the admissible ADTs (Graph,WGraph,stack,queue,PQueue,list) that your program is using, even if you use them unchanged. You can use dryrun as follows: CourseNana.COM

9024 dryrun tripView CourseNana.COM

Please note: Passing dryrun does not guarantee that your program is correct. You should thoroughly test your program with your own test cases. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
UNSW代写,COMP9024代写,Data Structures and Algorithms代写,TripView代写,C代写,UNSW代编,COMP9024代编,Data Structures and Algorithms代编,TripView代编,C代编,UNSW代考,COMP9024代考,Data Structures and Algorithms代考,TripView代考,C代考,UNSWhelp,COMP9024help,Data Structures and Algorithmshelp,TripViewhelp,Chelp,UNSW作业代写,COMP9024作业代写,Data Structures and Algorithms作业代写,TripView作业代写,C作业代写,UNSW编程代写,COMP9024编程代写,Data Structures and Algorithms编程代写,TripView编程代写,C编程代写,UNSWprogramming help,COMP9024programming help,Data Structures and Algorithmsprogramming help,TripViewprogramming help,Cprogramming help,UNSWassignment help,COMP9024assignment help,Data Structures and Algorithmsassignment help,TripViewassignment help,Cassignment help,UNSWsolution,COMP9024solution,Data Structures and Algorithmssolution,TripViewsolution,Csolution,