CS447/CS547/EE667 Fall 2008 Assignment 1 Due September 4 (in class) ----------------------------------------------------------------- 1. Recall the SS_100_k problem. There is an array S of positive integers, whose size is n, and a positive integer k. We want to determine if there is a subset of S, the sum of whose elements is equivalent to k mod 100. Assume the function SS_100,k has been run, as given below. Write a function to take S, A_new and k as inputs and print out the subset determined by SS_100_k. 2A. Recall the original SUBSET SUM problem. There is an array S of positive integers, whose size is n, and a positive integer k. We want to determine if there is a subset of S whose elements add up to k. Write an algorithm to solve SUBSET SUM which runs in time O(n k). 2B. Explain why your algorithm from part A is not polynomial in the size of the input. 3. Suppose we have a group of n men and n women, along with their heights. Write an algorithm to determine if it is posible for every man to marry a woman taller than him. No woman is allowed to marry more than one man. 4. Problem 3 in the textbook, page 22. SS_100_k(int S[1..n], int k) ---------------------------- int A[0..99] for j = 0 to 99 A[j] = -0 for i = 1 to n for j = 0 to 99 if A[j] != 0 and A[j] != i new_pos = (j + S[i]) mod 100 if A[new_pos] = 0 A[new_pos] = i if A[S[i] mod 100] = 0 A[S[i] mod 100] = i if A[k mod 100] != 0 print YES else print NO