Task 0: [20 marks]
As a warm up, consider the following problem where we are given as input k dance moves (d1, d2, . . . , dk)
and a non-negative strain factor si for each move di
, together with a sequence A of n moves.
(a) Describe an algorithm that computes RSI(A).
(b) Argue that your algorithm is correct.
(c) State and explain the complexity of you algorithm (in big-Oh notation).
(d) Implement your algorithm (submit this part to Ed). The input and output format is identical to
task 4, except the last line of input (B) is ignored, and the output is just a number.
Task 1: [20 marks]
Describe an algorithm for the DDR problem (“in plain English”). Your description needs to include
(a) A definition of the subproblems needed by your algorithm (i.e. what does the function OPT(. . .)
represent and what are its parameters).
(b) A definition of the recurrence(s) and base case(s) (i.e. what is the relationship between OPT(. . .)
for a subproblem in terms of OPT(. . .) for some other subproblems).
Task 2: [20 marks]
Justify the correctness of your algorithm. In particular, take care to prove that
• the recurrence is correct, and
• the base case(s) are correct and sufficient.
Task 3: [20 marks]
State and explain the complexity of your algorithm (in big-Oh notation). Consider both:
(a) Time complexity
(b) Space complexity
Make sure you justify the answers you give, do not merely state the values. Document Preview:
Algorithms 3027 Assignment 3 The University of Sydney2019 Semester 1 School of Computer ScienceThis assignment is for COMP3027 students only. If you have printed this using a black-and-white printer,look at the PDF on a computer to see the colors below.DescriptionCongratulations! You have been hired as the lead developer of the new Dance Dance Remix game. Inthis game, the player is given a sequence of dance moves and is scored based on how well he/she executesthe move. The key feature of this game is that instead of using a xed bank of sequences, it has a dancegeneration engine that generates them on-the- y by remixing existing sequences. More precisely, theengine takes two move sequences A and B and remixes them into a single sequence R by interleavingthe moves of A and B. The resulting sequence R is called a remix of A and B. Note that the moves ofA have to appear in R in the same order that they appear in A, and the same for the moves of B. Forexample, suppose the sequences A and B are as followsA = (spin;dab;dab;moonwalk;clap;moonwalk)B = (dab;dab;spin;clap;clap;moonwalk):then the following are remixes of A and B:spin, dab, dab, moonwalk, clap, moonwalk, dab, dab, spin, clap, clap, walkdab, spin, dab, dab, dab, spin, moonwalk, clap, clap, clap, walk, moonwalk(Note that the colors above are to help distinguish between moves that come from A and moves from B,dab and dab is the same move.)Some sequences are better than others in terms of the amount of strain it causes the player. Repeatingthe same moves over and over causes repetitive strain injury and certain moves such as spin are worsethan others. To model this, each dance moved is associated with a non-negative strain factors(d ) =s .i i iGiven a move sequence T , a repetition of d is a contiguous subsequence of T with at least 2 moves, andithe entire subsequence consists of only d . The strain of this repetition is the length of the repetitionitimess . The strain of a move…