MCD4710 Introduction to Algorithms and Programming 代写

  • 100%原创包过,高质代写&免费提供Turnitin报告--24小时客服QQ&微信:120591129
  • MCD4710 Introduction to Algorithms and Programming 代写

    Objectives
    The objectives of this assignment are:
    • To gain experience in designing algorithms for a given problem description and implementing those algo-
    rithms in Python 3.
    • To demonstrate the ability to:
    – Implement algorithms for sorting in Python.
    – Decompose code into functions in Python.
    – Implement simple recursive algorithms in Python.
    – Read from text files using Python.
    – Manipulate lists using basic operations.
    Submission Procedure
    1. Put you name and student ID in a comment at the start of each file in your solution.
    2. Save your files into a zip file called yourFirstName yourLastName.zip
    3. Submit your zip file containing your solution to Moodle.
    4. Your assignment will not be accepted unless it is a readable zip file.
    Important Notes:

    MCD4710 Introduction to Algorithms and Programming 代写
    1. Please ensure that you have read and understood the university’s policies on plagiarism and collusion
    available  at  https://www.monashcollege.edu.au/__data/assets/pdf_file/0010/17101/dip-assessment-policy.pdf.
    You will be required to agree to these policies when you submit your assignment.
    2. Where it would simplify the problem you may not use built-in Python functions or libraries (eg. using
    list.sort() or sorted()). Remember that this is an assignment focussing on algorithms and program-
    ming.
    3. Your program will be checked against a number of test cases. Do not forget to include comments in your
    code explaining your algorithm. If your implementations have bugs, you may still get some marks based
    on how close your algorithm is to the correct algorithm.
    4. For each task, you need to write a program that properly decomposes the problem. You will learn functions
    and decomposition in Week 6.
    Marks: This assignment has a total of 27 marks and contributes to 15% of your final mark. Late submission
    will have 5% off the total assignment marks per day (including weekends) deducted from your assignment mark.
    In the case of this Assignment, this means that a late assignment will lose 1.4 marks for each day (including
    weekends). Assignments submitted 7 days after the due date will normally not be accepted.
    1
    MCD4710 Assignment (15%)
    MCD4710 Introduction to
    Algorithms and Programming
    Due:  April 27, 2017, 5:00 pm
    Marking Criteria:
    Task 1: 9 marks
    (a) File read in correctly - 1 mark
    (b) Airport with highest send and receive capacity identified - 2 marks
    (c) Capacity of paths between airports calculated correctly - 3 marks
    (d) Results printed in clear manner - 1 mark
    (e) Code is readable (including meaningful variable names and non-trivial comments on code) - 1 mark
    (f) Code is appropriately decomposed - 1 mark
    Task 2: 9 marks
    (a) f(x) evaluated correctly - 1 mark
    (b) Recursive base case identified and implemented - 2 marks
    (c) Euler’s method implemented - 2 marks
    (d) Recursive case implemented correctly - 1 mark
    (e) Result printed in clear manner - 1 mark
    (f) Code is readable (including meaningful variable names and non-trivial comments on code) - 1 mark
    (g) Code is appropriately decomposed - 1 mark
    Task 3: 9 marks
    (a) Letters from A identified in B - 2 marks
    (b) Occurrences counted correctly - 2 marks
    (c) Occurrence counts sorted correctly - 2 marks
    (d) Results printed in clear manner - 1 mark
    (e) Code is readable (including meaningful variable names and non-trivial comments on code) - 1 mark
    (f) Code is appropriately decomposed - 1 mark
    2
    Task 1
    When organising flights for customers, a particular company, Wingit, likes to know how many people can fly
    in and fly out of each airport per hour. To help in knowing this, they create an undirected graph where the
    vertices are the airports and edges connecting them are weighted with the number of people that can travel
    between the airports per hour. For example, given the graph below, you can send 10 people per hour from A
    to B directly (without visiting other airports on the way) or vice versa.
    A B
    C
    D
    10
    5
    4
    6
    Part A
    For this part, you are to take in a file airports.txt in which the first line is a list of (space separated) airport
    names and the rest of the file contains an adjacency matrix (where the row/column numbers correspond to the
    order of the airports in the first line), describing the graph. Once the file has been read in, print out the name
    of the airport which can send or receive the most people at once.
    For example, the graph above would be described as:
    A B C D
    0 10 5 6
    10 0 4 0
    5 4 0 0
    6 0 0 0
    Given this input, the program would print A can handle the most passengers at 21 people per hour.
    Part B
    Next, the program is to accept two airport names (a source and destination), and prints the number of people
    that can be sent from one to the other in a single hour.
    For this, consider both how many people could fly directly from the source to the destination as well as how
    many could travel indirectly (via a single other airport). For the indirect path, you should consider some other
    airport X and determine the minimum of how many could travel from the source to X in half an hour and how
    many could travel from X to the destination in half an hour (rounding down).
    For example, given the graph specified above, if we ran the program it would ask for two airport names,
    in this case we’ll use A and C. This will give a result of 7 as we can send 5 directly between A and C. We can
    send another 2 through the path ABC as this is the minimum of half the weights of BC and AB. Adding the
    paths together gives the result of 7.
    Note: we do not consider D in this case as it does not have an edge leading directly to C.
    Please enter the two airports to consider (space separated): A C
    7 people can travel from airport A to airport C per hour
    As another example, we might consider D and C, in this case there is no direct path from D to C how-
    ever we can consider the path DAC. DAC would allow us to send 2 people (min(0.5*6, 0.5*5) = min(2.5,3) =
    2.5; as this is a decimal number we round down to 2)
    Please enter the two airports to consider (space separated): D C
    2 people can travel from airport D to airport C per hour
    You may assume that there is at least one edge in the graph and that the two airports given exist and a
    path exists between them.
    3
    Task 2
    When given a function f(x) which describes the gradient of another function g(x), it is possible to approximate
    g(x) when only f(x) and g(0) is known. One method for this is Euler’s method. This method works by starting
    at 0 and iteratively increasing x by a distance, h, until the desired value of x is reached.
    In each step, the next value of g(x) is calculated using:
    g(x + h) = g(x) + h × f(x) (1)
    In this task, ask the user for a value of y, h and g(0) and evaluate g(y) using the step size h from 0. Do this
    using a recursive function. Use f(x) = x 2 + 3x + 10 for the gradient function.
    For example, your program could do the following:
    Please enter a space separated set of values for y,h and g(0): 2 1 1
    g(2) = 25
    this was calculated using a step size (h) of 1 and an initial value (g(0)) of 1
    Note that for some values of y and h g(y) cannot be computed (for example if y is odd and h is 2); in this
    situation, your program should state that the computation is impossible with the given step size
    Task 3
    Write a program which asks the user for two strings, A and B. It must identify which letters (ignoring case)
    from A are in B and how many times each of these occur. Print the letters identified in this way in decreasing
    order by number of occurrence.
    For example, your program could do the following:
    Enter first string: abbc
    Enter second string: aAaabbccCCcccddeeffffggzba
    Letters found:
    7 c
    5 a
    3 b
    4

    MCD4710 Introduction to Algorithms and Programming 代写