代做FIT2004 2024 Semester 1: Assignment 1代写留学生Python语言

FIT2004 2024 Semester 1: Assignment 1

Learning Outcomes

This assignment achieves the Learning Outcomes of:

• Analyse general problem solving strategies and algorithmic paradigms, and apply them to solving new problems;

•  Prove correctness of programs, analyse their space and time complexities;

•  Compare and contrast various abstract data types and use them appropriately;

•  Develop and implement algorithms to solve computational problems. In addition, you will develop the following employability skills:

 Text comprehension.

•  Designing test cases.

 Ability to follow specifications precisely.

Assignment timeline

In order to be successful in this assessment, the following steps are provided as a suggestion. This is an approach which will be useful to you both in future units, and in industry.

Planning

1.  Read the assignment specification as soon as possible and write out a list of questions you have about it.

2. Try to resolve these questions by viewing the FAQ on Ed, or by thinking through the problems overtime.

3. As soon as possible, start thinking about the problems in the assignment.

• It is strongly recommended that you do not write code until you have a solid feeling for how the problem works and how you will solve it.

4. Writing down small examples and solving them by hand is an excellent tool for coming to a better understanding of the problem.

•  As you are doing this, you will also get a feel for the kinds of edge cases your code will have to deal with.

5. Write down a high-level description of the algorithm you will use.

6.  Determine the complexity of your algorithm idea, ensuring it meets the requirements.

Implementing

1.  Think of test cases that you can use to check if your algorithm works.

•  Use the edge cases you found during the previous phase to inspire your test cases.

•  It is also a good idea to generate large random test cases.

•  Sharing test cases is allowed, as it is not helping solve the assignment.

2.  Code up your algorithm  (remember decomposition and comments), and test it on the tests you have thought of.

3. Try to break your code.  Think of what kinds of inputs you could be presented with which your code might not be able to handle.

 Large inputs

•  Small inputs

 Inputs with strange properties

 What if everything is the same?

 What if everything is different?

 etc...

Before submission

 Make sure that the input/output format of your code matches the specification.

•  Make sure your filenames match the specification.

•  Make sure your functions are named correctly and take the correct inputs.

•  Remove print statements and test code from the file you are going to submit.

Documentation

For this assignment (and all assignments in this unit) you are required to document and com- ment your code appropriately. Whilst part of the marks of each question are for documentation, there is a baseline level of documentation you must have in order for your code to receive marks. In other words:

Insufficient documentation might result in you getting 0 for the entire question for which it is insufficient.

This documentation/commenting must consist of (but is not limited to):

• For each function, high-level description of that function.  This should be a two or three sentence explanation of what this function does.

• Your main function in the assignment should contain a generalised description of the approach your solution uses to solve the assignment task.

• For each function, specify what the input to the function is, and what output the function produces or returns (if appropriate).

• For each function, the appropriate Big-O or Big-Θ time and space complexity of that function, in terms of the input size.  Make sure you specify what the variables involved in your complexity refer to.  Remember that the complexity of a function includes the

complexity of any function calls it makes.

• Within functions, comments where appropriate.  Generally speaking, you would comment complicated lines of code (which you should try to minimise) or a large block of code which performs a clear and distinct task (often blocks like this are good candidates to be their own functions!).

A suggested function documentation layout would be as follows:

def my_function(argv1,  argv2):

"""

Function  description:

Approach  description  (if main  function):

:Input:

argv1: argv2:

:Output,  return  or postcondition: :Time  complexity:

:Time  complexity  analysis: :Space  complexity:

:Space  complexity  analysis:

"""

# Write  your  codes here .

There is a documentation guide available on Moodle in the Assignment section, which contains a demonstration of how to document code to the level required in the unit.

1    Question 1:  Ultimate Fuse

(10 marks, including 2 marks for documentation)

You are an adventurer in FITWORLD  a magical world where humans and FITMONs live in harmony.  FITMONs are insanely cute creatures   which make everyone around them happy. Each FITMON has a cuteness_score where a higher score means a cuter FITMON.

Recently, it was discovered that it is possible to fuse FITMONs together.  The fusing process could increase or decrease the cuteness_score of the resulting FITMON. Thus, you set out to fuse FITMONs together, to create the very cutest FITMON possible, that no FITMON ever was. In order to do so, you head over to a FITMON Center.

1.1    Input

You have a list of fitmons:

•  Contains N fitmon in the list [0...N − 1].  N isanon-zero, positive integer where N > 1.

 Each fitmon is identified by their index in the fitmons list.

 Each fitmon in the list is a list of 3 values

[affinity_left,  cuteness_score,  affinity_right] .

•  affinity_left is a positive float in the range of 0.1...0.9 inclusive.  Only the left-most fitmons[0] will have an affinity_left of 0 as there isno fitmon on the left for it to fuse.

•  affinity_right is a positive float in the range of 0.1...0.9 inclusive.  Only the right-most fitmons[N-1] will have an affinity_right of 0 as there isno fitmon on the right for it to fuse.

•  cuteness_score is anon-zero, positive integer.

An example of the input list fitmons is illustrated below:

fitmons  =  [

[0,  29,  0.9],

[0.9,  91,  0.8], [0.8,  48,  0.2], [0.2,  322,  0]

]

In this input, fitmons[1] has a:

  affinity_left of 0.9.

•  cuteness_score of 91.

  affinity_right of 0.8.

1.2    Fusing Logic

From the fitmons list, you realize that each fitmon can only fuse with the adjacent fitmon in the adjacent fitmon. Your goalis to fuse all of the given fitmons into only 1 fitmon.  Thus:

 fitmons[i] can only fuse with either fitmons[i-1] or fitmons[i+1].

• The affinity for the 2 fusing fitmons are the same as illustrated in the example input. We see that fitmons[i][0] would have the same value as fitmons[i-1][2] and similarly fitmons[i][2] would have the same value as fitmons[i+1][0].

 However, fitmons[0] can only fuse with fitmons[1] as there isno fitmon on its left.

• Likewise, fitmons[N-1] can only fuse with fitmons[N-2] as there isno fitmons on its right.

•  Once a fitmon is fused, it no longer exist and thus cannot be used for fusing again.

When 2 fitmons fuse, their cuteness changes based on their cuteness_score and the affinity of the fuse. Fusing fitmons[i] with fitmons[i+1] will create a new fitmon with:

• The affinity_left will be based on the affinity_left of the left fitmon, affinity_left  =  fitmons[i][0]

• The cuteness_score is computed using the affinity_score of the fusing fitmons mul- tiplied with their cuteness_score based on the following equation,

cuteness_score  =  fitmons[i][1]  *  fitmons[i][2]  +

fitmons[i+1][1]  *  fitmons[i+1][0]

• The affinity_right will be based on the affinity_right of the right fitmon, affinity_right  =  fitmons[i+1][2]

• Note: as the cuteness_score is an integer, you can use int() on it after each and every fuse; before the next fuse (if any).

Using the example input earlier:

 Fusing fitmons[0] with fitmons[1], will produce a fitmon with the value of [0, 108, 0.8].

 Fusing fitmons[1] with fitmons[2], will produce a fitmon with the value of [0.9, 111, 0.2].

 Fusing fitmons[2] with fitmons[3], will produce a fitmon with the value of [0.8, 74, 0].

Therefore, you implement a function called fuse(fitmons) which accepts the list fitmons and this function would fuse all of the fitmon in the list into a single ultimate final fitmon.  The resulting fitmon will have the highest possible cuteness_score from the fusing.

1.3    Output

The fuse(fitmons) function would return an integer, where it is the cuteness_score of the highest possible cutenness_score from fusing all of the fitmons – if there are N fitmonns then you would need N − 1 fuses in total.  We illustrate a simple example in the next section 1.5.

1.4    Complexity

The function fuse(fitmons) must run at the worst-case, O(N3 ) time and O(N2 ) space where N is the number of items the list fitmons.  It is possible for your solution to run better than the complexity stated here.

1.5    Example

Consider the following input list of fitmons with a total of 3 fitmon in it.

fitmons  =  [

[0,  29,  0.9],

[0.9,  91,  0.8], [0.8,  48,  0]

]

 

Figure 1: The 3 FITMONs from the input.

We can proceed to fuse any 2 of the fitmons in Figure 1 as long as they are next to each other. As a start, we can choose to fuse fitmons[0] with fitmons[1], creating a fitmon with the stats of [0, 108, 0.8] as illustrated below in Figure 2:

 

Figure 2: Fusion of fitmons[0] with fitmons[1].

Then we can fuse this new fitmon with fitmons[2], creating the final fitmon with the stats of [0, 124, 0] as illustrated below in Figure 3.

 

Figure 3: Fusion of fitmons[0] with fitmons[1], which is then fused with fitmons[2] after.

Alternative, the fusion can be done as illustrated in Figure 4 where we first fuse fitmons[1] with fitmons[2] first. Then fitmons[0] is fused with the resulting fitmon. This creates the final fitmon with the stats of [0, 126, 0].

 

Figure 4: Fusion of fitmons[1] with fitmons[2], which is then fused with fitmons[0] after.

Putting both fusion order side by side as in Figure 5, we can see that the latter fusion order described (the one on the right) resulted in a cuter final fitmon with a cuteness_score of 126.

 

Figure 5: Side-by-side comparison of the fusing orders described earlier.  Left has a fusion order of ((0, 1), 2) and right has a fusion order of (0, (1, 2)).

In summary, the example above can be run using the following code snippet with the resulting returned values.

>>>  fuse([[0,  29,  0.9],  [0.9,  91,  0.8],  [0.8,  48,  0]]) 126

To aid your exploration, consider the following additional examples:

In the example below, the same fitmons have been swapped around while retaining their cuteness_score and affinity_score. This different order will still produce the same optimal fused fitmon with the highest cuteness_score of 126.

>>>  fuse([[0,  48,  0.8],  [0.8,  91,  0.9],  [0.9,  29,  0]]) 126

>>>  fuse([[0,  50,  0.3],  [0.3,  50,  0.3],  [0.3,  50,  0]]) 24

For the above example, there are several observations to be made.  Firstly, all of the fitmons have the same cuteness_score and the same affinity_score. Thus, the order of their fusing does not matter.

Fusing them alltogether will produce a final fitmon with a cuteness_score of 24.  This value is less than the original cuteness_score but as you need to always fuse all of the fitmons together, you have no choice but to accept a less cute final outcome.  The same can be observed with the next 2 examples below:

>>>  fuse([[0,  50,  0.6],  [0.6,  50,  0.3],  [0.3,  50,  0]]) 48

>>>  fuse([[0,  50,  0.3],  [0.3,  50,  0.3],  [0.3,  80,  0]]) 33

As for the example below, it is just an example of a larger input.  Do note that your solution would be tested against very large input sizes in the range of thousands.

>>>  fuse([[0,  50,  0.6],  [0.6,  98,  0.4],  [0.4,  54,  0.9],  [0.9,  6,  0.3],   [0.3,  34,  0.5],  [0.5,  66,  0.3],  [0.3,  63,  0.2],  [0.2,  52,  0.5], [0.5,  39,  0.9],  [0.9,  62,  0]]  )

132

It is important to note that the examples provided are not exhaustive.There are many other possible cases, with specific edge cases which you would need to validate for your solution to ensure correctness.  Thus, do ensure your solution is sufficiently tested using techniques you have learnt in prerequisite units such as unit-testing.

2    Question 2:  Delulu is not the Solulu

(10 marks, including 2 marks for documentation)

You are a bear stuck in the forest and would like to escape the forest.   Unfortunately, the forest itself is known as the Delulu Forest where it is easy to get lost. Your ancestors have left markings on various large trees in the forest to help you escape the forest, where each of the large tree will provide a road to one or more other large tree.  This is drawn onto a treemap that is given to you:

• There area total of |T| trees in the forest, from t0  all the way to t|T|−1 .

•  One of the trees would be start which is where you begin from.

•  One or more trees would be exits which is where you can exit from. These trees would be marked in the treemap given to you.

• There are |R| roads in total connecting the trees, from r0  all the way to r|R|−1 .

• You can go from tree-u to tree-v if a road r = (u,v) exist.  However, you can’t go from tree-v to tree-u unless the opposite road r′  = (v, u) also exist in the treemap.

• It takes w-minutes to travel along the road r = (u,v, w).  The travel time could differ between, and all of the time to travel along the road is stated in the treemap itself.

You then find out the reason why it is called the Delulu Forest – the exit is nothing but a delusion and even after reaching the exit tree, you are still stuck in the forest due to the seal of the forest.  However, your ancestor left a hint – certain trees are Solulu trees. You can claw at the tree to destroy that Solulu tree. Doing so will undo the seal of the forest, and then you will be able to exit the forest at an exit tree.

• There are |S| Solulu trees in the forest, from s0  all the way to s|S|−1 .

 You would require y-minutes to claw at a Solulu tree-s in order to destroy it.

•  Some Solulu trees will teleport you to another tree-t upon destruction.  This teleportation might bring you closer to, or further from your exit.

You can’t bear to be in the forest anymore and would want to escape as soon as possible.  Thus, you use your pawsome computer science knowledge of Graphs to find figure out the quickest way to exit the Delulu forest. You would model the treemap using the graph ADT as follow:

class  TreeMap:

def      init     (self,  roads,  solulus):

#  ToDo:  Initialize  the  graph  data  structure here.

More  details  to be  described  in  Section  2 . 1 def  escape(self,  start,  exits):

#  ToDo:  Performs  the  operation needed  to  find  the  optimal  route . More  details  to be  described  in  Section  2 . 2








热门主题

课程名

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