代做COMP 2402 ABC - Fall 2024 - Abstract Data Types and Algorithms Assignment 5代写Java程序

Abstract Data Types and Algorithms

COMP 2402 ABC - Fall 2024

Assignment 5

Due: Tuesday, December 3, 23:59

Download the Provided Files

The base code for this assignment consists of one zip file, which you can download from Brightspace: comp2402a5.zip - source code. This file contains a folder named comp2402a5 with five .java files:

•    AdjacencyLists.java

•    Algorithms.java

    Graph.java

•    MixAndBoom.java - add your code here

•    SnakesAndLadders.java - add your code here

Start by reviewing the skeleton code. Unlike the previous three assignments, this one does NOT include a slow (correct) implementation. However, a custom-made Graph interface is provided, along with the associated classes AdjacencyLists and Algorithms. The Algorithms class contains useful methods that can assist you with your assignment.

Additionally, you are also provided with sample input and output files, available as a zip file: a5-io.zip.

Use these files to familiarize yourself with testing your code. Once you understand how to work with the provided input and output files, create your own tests to thoroughly evaluate your program. Note that the provided tests are not exhaustive and are meant to serve as a starting point.

Grading

This assignment will be tested and graded by a computer program also known as an auto-grader. You can submit as many times as you like; your highest grade is recorded. For this to work, there are some important rules you must follow:

•    Keep the directory structure of the provided comp2402a5.zip file. If you find a file in the subdirectory comp2402a5 leave it there.

•    Keep the package structure of the provided zip file. If you find a  package comp2402a5; directive at the top of a .java file, leave it there.

•    Keep the interfaces as they are. You may add internal methods to your implementation, but do not introduce any new methods to the interfaces.

•    Do not rename or change the visibility of any methods already present. If a method or class is public, leave it that way.

•    Submit early and often. The auto-grader will compile and run your code, providing you with instant feedback and a grade. You can submit as many times as you like – your final grade will reflect your last submission. Alternatively, you can choose to activate your highest-graded

submission as your final score. With this flexibility, there’s no excuse for submitting code that doesn’t compile or fail the tests.

•    The assignment consists of two independent parts, each of which will be graded separately by the auto-grader.

•    The goal for this assignment is to write efficient code. If you select and implement your data structures correctly, your code will execute efficiently within the time and memory limits.

However, if you choose inappropriate data structures or misuse them, your code may run too slow to be graded by the auto-grader, resulting in a grade of 0.

•    The auto-grader places a time limit on how long it will be executing your code, often testing with over a million elements and operations.

•    Memory usage is also capped.

Submitting and Testing

Submitting to Gradescope is simple: drag and drop ALL your .java files into the submission window provided. If you encounter any issues, please post them on Discord so the teaching team (or your classmates) can assist you. Including screenshots can help resolve problems more quickly.

When you submit your code, the auto-grader runs numerous tests on it. We will not disclose the tests used by the auto-grader, because you should try to find exhaustive tests of your own code. You are encouraged to create your own tests and test locally before trying your submission on Gradescope. Keep in mind that the auto-grader has a strict time limit of 5 seconds pertest case. Any test that exceeds this   limit will be marked as failed, and subsequent tests for that part will not be executed. For larger test cases, even an optimal implementation may take up to 3 seconds, and this time could increase if the server is heavily loaded. To avoid potential issues, please begin submitting your assignment well in advance of the deadline.

Start by downloading and decompressing the Assignment 5 Zip File (comp2402a5.zip), which contains a   skeleton of the code you need to write. The skeleton code in the zip file compiles fine. You can unzip the file (extract its content) in numerous ways, such as by drag-and-drop or right-mouse-click “Extract all” .     Here's what it looks like when you unzip and compile it from the command line (the commands that you type are highlighted in yellow):

> unzip comp2402a5.zip

Archive:  comp2402a5.zip

inflating: comp2402a5/AdjacencyLists.java inflating: comp2402a5/Algorithms.java

inflating: comp2402a5/ Graph.java

inflating: comp2402a5/MixAndBoom.java

inflating: comp2402a5/ SnakesAndLadders.java > javac comp2402a5/*.java

Here is an example of how to use command-line arguments to do your own testing. Make sure your

terminal is open in the folder that contains the folder comp2402a5 with your .java files. Add your input test file, for example part1-1.in, to the folder your terminal is in.

> java comp2402a5.MixAndBoom part1-1.in yes

Execution time: 0.0017132

This way, you do not need to type input line by line, but rather provide it as a file via command-line arguments. Now you can compare your output to the correct output provided in part1-1.out file.

If you are having trouble running these programs, figure this out first before attempting to do the assignment. If you are stuck, ask on Discord, and our teaching team or another student will likely help you fairly quickly.

The Assignment

This assignment consists of two main parts:

•    For part 1, implement the doIt() method in the MixAndBoom class.

•    For part 2, implement the doIt() method in the SnakesAndLadders class.

To assist you, a custom Graph interface has been provided, along with its related classes

(AdjacencyLists and Algorithms). You might find these classes helpful. Also, you are welcome to modify some of the methods from Algorithms and use them in your solution.

Part 1: Mix And Boom [50 marks] Professor Mixiten Kaboom is a famous chemist who is constantly inventing new chemicals. Unfortunately, for some strange reason, some of his chemicals tend to explode when mixed with some of the other chemicals. To make things even worse, he has only two storage compartments in his lab. The only way to store the chemicals safely is to divide them between the compartments so that no two chemicals that explode when mixed arestored in the same compartment. Earlier, when the number of chemicals was small, the professor could do it easily. But now that he has accumulated so many chemicals over the years, the task has become too time- consuming. He asks for your help solving this problem. Given N chemicals and a list of chemical pairs

that explode when mixed, you will have to write a program that determines if it is possible to store them using the two storage compartments.

The input begins with an integer in a single line, which is the number of chemicals the professor has. The chemicals are numbered from 1 to N. Next, there is a sequence of lines, each containing a pair of   integers (between 1 and N inclusive), representing two chemicals that explode when mixed. If it is possible to store the chemicals safely, your program should output “yes”, and “no” otherwise.

Part 2: Snakes And Ladders [50 marks] A worldwide classic boardgame. Navigate your token from start  to finish, avoid the snakes (something you should consider) and take shortcuts going up the ladders. The board is a grid of squares numbered from 1 to the final square. For our assignment, assume the board is  an N-by-N matrix.

The rules of the boardgame "Snakes and Ladders" are simple:

•    Each player starts at location 1 and takes turns to move their token forward.

•    Players take turns rolling a six-sided dice to determine how many squares they will move on their turn.

•    Move your token forward along the board the number of squares shown on the dice.

•    If your token lands on asquare at the base of a ladder, you can immediately climb the ladder to the square at the top.

•    If your token lands on a square with the mouth of a snake, you must slide down to the square at the snake's tail.

•    The first player to reach or exceed the final square is the winner of the game.

Imagine that you have a magical six-sided dice that rolls any number you want between 1 and 6. Given a board of size N-by-N, a configuration of snakes and ladders, and the magical six-sided dice, you must determine the minimum number of dice rolls you will need togo from location 1 to location N*N.

The input begins with an integer in a single line, which represents the board dimension N. Next, there is a sequence of lines, each containing a pair of integers (between 1 and N*N inclusive), representing

either aladder or a snake. A ladder is represented by a pair where the  first number is smaller than the

second, and the opposite for snakes.

You may assume that no ladder

starts at the first square (1), and no snake starts at the last square

(N*N).

Your program should output a  single integer representing the minimum number of dice rolls  required to reach the location  N*N.

Example of the board 

Tips,Tricks, and FAQs

Take time to plan your solution carefully before starting to code. Here are some tips to guide you:

•    You may have already figured out that this assignment revolves around graphs. Consider how each problem can be framed as a graph problem, then design an algorithm to solve it.

•    Sketch a sample graph and manually simulate your algorithm step by step. Test it on different examples to ensure it works in all cases.

•    Once confident in your algorithm, begin implementation. The provided Graph class is a great starting point for testing, - some basic algorithms are already included for reference.

•    You can save memory usage by NOT storing unnecessary information when the graph is sparse.

How should Itest my code?

For this assignment, you will have to test your own code thoroughly. The auto-grader will perform a

range of tests on your implementation, but it does not give much information when things go wrong.    The auto-grader cannot determine logical errors from crash reports, and the responsibility falls on the  programmer. You are advised to write your own tests and test your code locally, where you have more control over debugging your code.

•    Use the sample input/output files as a starting point to understand the required format. Then, make your own input files and test your solutions with them.

•    Test for both correctness and speed. Write the correct code first, and then focus on optimizing its speed.

•    All the tests on the server are heavily memory constrained. Be careful with how much memory your solution takes.

•    In some cases, your solution maybe acceptably fast but too memory-intensive, which may lead to timeout because of how the JVM garbage collector behaves on the server.

•    Test incrementally. Start with small, simple testcases that can be solved manually. Gradually   increase the complexity to include edge cases, large inputs, empty inputs, and random inputs.

•    Avoid leaving unnecessary debugging print statements (System.out) in your code. These can slowdown execution or cause crashes if the output is too large. Remove them before submitting your work to the auto-grader.


热门主题

课程名

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
站长地图