代做MA214 Algorithms and Data Structures 2024代做Python编程

Assessed Coursework

MA214

Algorithms and Data Structures

due: Tuesday, 23 April 2024 at 16:00 (London time)

Instructions

This set of tasks is Assessed Coursework, constituting 20% of the final mark for this course. It is due on Tuesday, 23 April 2024 at 16:00 (London time).

The work should be yours only. You may not work in groups or even discuss these problems with anyone else. You have to upload your work on Moodle at the Gradescope link that will be provided. By submitting your solutions, you are confirming that you have read and understood the School’s rules on Plagiarism and Assessment Offences, which can be found here and here. In these rules it is also explained which procedure we will follow should we suspect collusion or any other form. of assessment offence or plagiarism for your submission.

Your submission for this coursework should consist one file only: A Python file Submarines.py (which should also contain, in comments, explanations about the algorithms and data structures you chose for your imple-mentation and the resulting running times, as explained in detail in the tasks below). A template for this python file is provided on the course moodle page.

The contents of your work must remain anonymous, so do not include your name or your student number in the files. Do not submit anything directly to your lecturer or class teacher. Instead, please put your candidate number in the submitted file in a comment at the very top.

The deadline is sharp. Late work carries an automatic penalty of 5 deducted marks (out of 100) for every 24-hour period that the coursework is late.

Submission of answers to this coursework is mandatory. Without any submission, your mark for this course is incomplete, and you may not be eligible for the award of a degree.

Use of internet search, generative AI, and Python packages

In addition to all the course material provided on the course webpage and the course textbooks, you are of course allowed (and in fact encouraged) to use online documentation on the Python programming language to assist you when writing your programs, and there is no need to report this.

No other resources are necessary for completing this coursework. However, should you decide to use other resources (such as Stack Exchange or ChatGPT) to get ideas for your algorithms, their implementation, or their analysis, these need to be acknowledged and documented in order to adhere with the rules concerning plagiarism mentioned above. Please document the use of such tools at the very end of your submission file in a comment. For generative AI tools, you need to provide a transcript. of the chat, or a link to the chat. You will not gain points for answers taken from such sources, but only for your own work.

In your Python programs for this assessed coursework, you are not allowed to use any Python library functions apart from the following imports which are already contained in the template-file that is provided on moodle.

from collections import deque

from math import inf

The aim of this assessment is not to measure your proficiency in using Python packages to solve problems. The questions test your algorithm design and analysis skills, as well as your ability to implement algorithms in Python.

Coursework MA214 – Submarine journey planner

You were hired as an expert in algorithms and data structures by a company specialising in public underwater submarine lines operating between different underwater colonies. Your first project concerns the design of software for storing and obtaining information about the submarine lines that are operating and to facilitate journey planning. For this purpose you should write a Python program in a file Submarines.py with the functionality and output as specified below (see Tasks 1–4). In order to demonstrate your value as expert to the company, you are also required to justify the design of your algorithms and analyse their running time (see Task 5).

The setup is as follows. There are a number of submarine lines, each stopping at a given sequence of un-derwater terminals at specified times. For simplicity, we shall assume that the departure time of a given submarine at a terminal is the same as its arrival time at this terminal (and we simply call it the stopping time). At terminals, passengers may change between different lines A and B, as long as A arrives before or at the same time as B. In particular, we assume, again for simplicity, that changing between lines does not require any time. Also, a time is simply given as a number of minutes since the start of the day and each submarine line reaches its final destination on the same day as it started. A line does not stop at any station twice.

For completing the following tasks, you will have to consider carefully which data structures to use for storing the given information and to support your algorithms. The different tasks below will influence your design decisions. It is therefore important that you read the entire coursework description in detail before you start coding.

Use the template for Submarines.py that is provided on the course moodle page and complete the functions as specified in the tasks below. Of course, you are also encouraged to add other functions and classes to this file that you need for your implementation or for the data structures you would like to use. You can (without acknowledgement) copy code from the Python files provided on the course moodle page if this helps you. It is important that you do not change the number of arguments or the names of the functions you are asked to implement in the tasks below, so that your program will work with the autograder that is used upon submission. You are welcome (but you do not need) to change the content of the “main” block (that comes after if __name__== '__main__':), which is not used by the autograder.

The intention of the class SubmarineNetwork in Submarines.py is that it allows us to store all the information about the submarine lines and to perform. journey planning tasks. In its methods, that you are asked to implement as described below, you may assume without checking that all input arguments are provided in the correct format. For example, when a time is expected as input argument, you may assume that a non-negative integer is provided; or when a Python list of pairs is expected as input argument that such a list is provided.

Your first task is to set up a constructor for the class Submarines.py and a method for adding new subma-rine lines. (It is likely that you will need to update your implementation of the constructor once you are implementing the other functions as described below.)

Task 1.                                   4 points

Implement the constructor __init__(self) and the member function add_line(self,stops) of the class SubmarineNetwork. The constructor should set up all the member variables you need in SubmarineNetwork. The function add_line should allow us to add a submarine line to the network and gets a Python list stops as argument whose entries are pairs (name,time) specifying the schedule for this line as follows. Each pair consists of a name of a terminal and a stopping time (in minutes) at this terminal; the pairs are ordered by time (that is, first the first stop is given, then the second, and so on).

Each added submarine line should also be assigned a line id: The line that is added first gets id 0, the line that is added next gets id 1, and so on.

For example, using

network = SubmarineNetwork ()

network . add_line ([ ('South Sea ' ,12) , ('Indian Ocean ' ,52) ,

                               ('Coral Reef ' ,74) , ('Polar Lagoon ' ,123) ])

should create a submarine network with one line which has id 0 and is stopping at ‘South Sea’ at minute 12, at ‘Indian Ocean’ at minute 52, and so on.

Next, we would like to add some functionality to obtain timetable information for a given terminal.

Task 2.                                          2 points

Implement the member function

lines_stopping_at(self,terminal_name,start_time,end_time)

of the class SubmarineNetwork. This function should return a Python list of pairs (id,time) giving the ids and stopping times of lines stopping at the terminal with the provided name between start_time and end_time (both inclusive). The tuples in the python list should be ordered by time.

For example, if in the network line 0 stops at the terminal ‘South Sea’ at time 10, line 1 stops there at time 23, line 2 stops there at time 14, and line 3 stops there at time 20, then running

network.lines_stopping_at('South Sea',14,23)

should return

[(2,14),(3,20),(1,23)].

We further want to obtain information about a fastest direct connection between two submarine terminals.

Task 3.                                           4 points

Implement the member function

best_direct_connection(self,origin,destination,time)

of the class SubmarineNetwork. This function is given the name of the origin terminal where we would like to start our journey, the name of the destination terminal we would like to travel to, and a time at or after which our journey should start. This function should determine the line that we should take from the origin to the destination in order to arrive at the destination as early as possible. The function should return a triple (id,t_o,t_d) containing the id of the line we should take, the time t_o when this line stops at the origin and the time t_d when this line stops at the destination.

For example, if in the network the fastest direct connection at or after time 20 from origin ‘Mariana Trench’ to destination ‘Mid-Atlantic Fault’ uses submarine line 2, which leaves the origin at 23 minutes, and arrives at the destination at 42 minutes, then running

network.best_direct_connection('Mariana Trench','Mid-Atlantic Fault',20)

should return (2,23,42).

We also would like to be able to determine the fastest connection between two submarine terminals when changes between different submarine lines are allowed. For this purpose we can use a variant of Dijkstra’s algorithm.

Task 4.                                                     4 points

Modify Dijkstra’s algorithm suitably to implement the member function

next_fastest_connection(self,origin,destination,time)

of the class SubmarineNetwork. This function is given the name of the origin terminal where we would like to start our journey, the name of the destination terminal we would like to travel to, and a time at or after which our journey should start.

The function should return a list of triples (name,time,id), giving name of the terminals through which we pass on our journey, the time at which we leave this terminal, and the id of the line on which we leave the terminal unless it is the destination; for the destination time should be the arrival time at the destination and id should be None.

For example, assume in our network the next fastest connection from ‘South Sea’ to ‘Coral Reef’ leaving at or after time 42 uses line 2 at 58 minutes to go to ‘Polar Lagoon’, where it stops at 78 minutes, continues onwards on line 2 to ‘Brazil Basin’, where it stops at 120 minutes, then uses line 5 which leaves ‘Brazil Basin’ at 132 minutes to go to ‘Indian Ocean’, where it arrives at 159 minutes, then uses line 0 which leaves ‘Indian Ocean’ at 159 minutes and goes directly to ‘Coral Reef’, arriving there at 164 minutes. Then running

network.next_fastest_connection('South Sea','Coral Reef',42)

should return the following Python list.

[( 'South Sea ' ,58 ,2) ,('Polar Lagoon ' ,78 ,2) ,('Brazil Basin ' ,132 ,5) ,

('Indian Ocean ' ,159 ,0) ,('Coral Reef ' ,164 , None ) ]

The template-file for Submarines.py also provides a more complex example for how all the methods of SubmarineNetwork can be used together.

Remember to explain all your code well with comments. In addition, add the following comments concerning the design and analysis of your implementation. Recall that you can start and end multi-line comments in Python by using '''.

Task 5.                                                      6 points

At the start of your file Submarines.py explain the design of your program: Which data structures are you using for storing the necessary information and why? Which algorithms are you using for implementing the different functions? Which auxiliary classes and functions are you incorporating and why?

Also, at the start of each of the functions

add_line, lines_stopping_at , best_direct_connection, next_fastest_connection

explain what is the running time of your implementation. Justify your answers.

Your solutions will be marked for correctness, design, readability, efficiency, and your provided explanations. When making design decisions think carefully about which methods are likely to be used more frequently and should therefore have small running times.





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图