HW3_April2018_answers.pdf

# Part b sort the employees by skill level and sort the

This preview shows pages 1–2. Sign up to view the full content.

Part b: Sort the employees by skill level, and sort the tasks by difficulty level. Then assign the least skilled worker to the easiest task, the second- least skilled worker to the second-easiest task, etc. Q3 : Set P (0 , 0) = True. Set P (0 , W ) = False for all W > 0. Set P ( i, 0) = True for all i . Then to calculate P ( i, W ), we need solutions to P ( i - 1 , W ) and P ( i - 1 , W - v i ) (the first corresponds to the case when coin i is not used, and the second corresponds to the case when it is used). If either of these two subproblems is True, then set P ( i, W ) = True. We need to solve the subproblems in the correct order. To solve the subproblem for coin i , we should solve all subproblems for coin i - 1 first. So if we go in increasing order of i , we will accomplish this. As we iterate over the i values, it doesn’t matter what order we consider the various W orders in, so let’s just say we go in increasing order of W . Q4 : Define C [ i ] to be the cheapest way to get to rental shop i . If you stop at shop i , you could have potentially stopped at any of the previous shops along the river immediately before you got to shop i . These are the subprob- lems. If you know the cost to get to shop j , where j < i , then how can you use that to figure out the cost to get to shop i ? You can use either a one dimensional array or shortest path algorithm for DAGs to answer this ques- 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
tions. To be able to keep track of the shops define a one dimensional array prev where prev [ i
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern