# HW2 - Fall Semester 2008 CS300 Algorithms Homework#2(due...

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

Fall Semester 2008 CS300 Algorithms Homework #2 (due 10/10) 1. We can recursively define the number of combinations of m things out of n , denoted ( n m ) , for n 1 and 0 m n , by ( n m ) = 1 if m = 0 or m = n ( n m ) = ( n - 1 m ) + ( n - 1 m - 1 ) if 0 < m < n (a) Give a recursive function to compute ( n m ) . (b) What is its worst-case running time as a function of n ? (c) Give a dynamic programming algorithm to compute ( n m ) . Hint 1 The algorithm constructs a table generally known as Pascal’s triangle. (d) What is the running time of your answer to (c) as a function of n ? 2. Suppose you are consulting for a company that manufactures PC equipment and ships it to distributors all over the country. For each of the next n weeks, they have a projected supply s i of equipment (measured in pounds), which has to be shipped by an air freight carrier. Each week’s supply can be carried by one of two air freight companies, A or B. Company A charges a fixed rate r per pound (so it costs r × s i to ship a week’s supply s i ).

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

View Full Document
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