CS4335 Assignment 3 Lecturer: Lusheng Wang Due on Dec 2nd, 2013 8pm Each 24 hours late submission halves the score. Submission: Hardcopy is required. Hardcopy to the MailBox74(Floor 6, lift 9). For all the problems in this assignment, STATE the running time of your methods. Question 1: Dancing List (50%) A club wants to organize a party for the students. However, only part of the students can attend the party. The candidates are choosing by pairs with the following requirements: assume the students are lined-up, each student is given a lucky number, and some students may have the same lucky numbers. The club requires that only students who have the same luck numbers may be paired-up and join in the party while all the students locate within a chosen pair will lose the opportunity. We have helped the club to formulate the problem formally. Given a sequence of positive integers (represent the lucky numbers) A = (a1, a2, ... an), a pair (ai, aj) is defined as a dancing pair if ai=aj, and i<j. A dancing pair list L={(𝑎𝑖1 , 𝑎𝑗1 ),… (𝑎𝑖𝑘 , 𝑎𝑗𝑘 ) } is good if and only if for any two pairs (𝑎𝑖𝑥 , 𝑎𝑗𝑥 ), (𝑎𝑖𝑦 , 𝑎𝑗𝑦 ) of L, either jx<iy or jy<ix for 1 ≤ 𝑥, 𝑦 ≤ 𝑘. For example, if A={1, 3, 4, 1, 2, 3, 2, 4, 3, 5, 3, 4, 5}, some good dancing lists might be: {(1, 1), (2, 2), (3, 3)} {(1, 1), (3, 3) (5, 5)} {(3,3),(4,4)} {(3,3), (5,5)} Now your tasks are to help the club to identify the candidates; that is, a) Given a sequence of positive integers A, design a polynomial time algorithm to find a good dancing pair list with maximum number of dancing pairs. b) Assume the weight of the dancing pair (ai, aj) is ai+aj. The total weight of a good dancing list is the sum of all the weights of the dancing pairs in the list. Design a polynomial time algorithm to find a good dancing pair list with maximum total weight. CS4335 Assignment 3 Lecturer: Lusheng Wang Due on Dec 2nd, 2013 8pm Each 24 hours late submission halves the score. Submission: Hardcopy is required. Hardcopy to the MailBox74(Floor 6, lift 9). Question 2: Maximum multiplication subsequence (50%) Lisa will graduate next year, and she wants to find a good job, and build a career path. An ideal career path to her is that the salaries are never decreasing, and ideally, are always multiplying. One day, Lisa met a fortune teller, and was told a sequence of jobs to choose. Lisa has not taken CS4335, and she asked your help to design a method to choose the jobs. Again, we have formulated the problem formally. A is a sequence of positive integers (represents the salaries): A = (a1, a2, ... an). A multiplication subsequence of A is a subsequence S=(𝑎𝑖1 , 𝑎𝑖2 , … , 𝑎𝑖𝑘 ) satisfies that (1) S is obtained by remove some entries of A sequentially; that is, i1<i2<i3<...<ik, 𝑎𝑖𝑙, 1≤𝑙≤𝑘 is in A; and (2) 𝑎𝑖2 is a multiple of 𝑎𝑖1 , 𝑎𝑖3 is a multiple of 𝑎𝑖2 , …; that is, 𝑎𝑖𝑙+1 𝑖𝑠 divisible by 𝑎𝑖𝑙 is zero for . 1≤l<k . For example, if A =(1, 2, 3, 3, 4, 5, 6, 7, 8, 15), then (1, 2, 4, 8), (1, 3, 3, 6), and (1, 3, 15) are multiplication subsequences of A. a) Given a sequence of positive integers A, design a polynomial time algorithm to identify a longest multiplication subsequence. b) Define the weight of a sequence as the sum of the elements in the sequence. Design a polynomial time algorithm to identify a maximum weighted multiplication subsequence.