{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hbs4 - we can make by cutting up and selling our rod of...

This preview shows page 1. Sign up to view the full content.

CS 473: Algorithms, Fall 2010 HBS 4 Problem 1. [Largest Complete Subtree] For this problem, a subtree of a binary tree means any connected subgraph. A binary tree is complete if every internal node has two children, and every leaf has exactly the same depth. Describe and analyze a recursive algorithm to compute the largest complete subtree of a given binary tree. Your algorithm should return the root and the depth of this subtree. Figure 1: The largest complete subtree of this binary tree has depth 2. Problem 2. [Rod Cutting] Suppose we are given a steel rod of length n . Also, assume we are given an array p [1 . . . n ], where p [ i ] is the price a rod of length i sells for. Given that we can make cuts for free (and that we only cut integer lengths), provide an algorithm that efficiently computes the maximum amount
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: we can make by cutting up and selling our rod of length n . Problem 3. [Billboards] Consider a stretch of Interstate-57 that is m miles long. We are given an ordered list of mile markers, x 1 ,x 2 ,...,x k in the range 0 to m , at each of which we are allowed to construct billboards (suppose they are given as an array X [1 ...k ]). Suppose we can construct billboards for free, and that we are given an array R [1 ...k ], where R [ i ] is the revenue we would receive by constructing a billboard at location X [ i ]. Given that state law requires billboards to be at least 5 miles apart, give an eﬃcient algorithm to compute the maximum revenue we can acquire by constructing billboards. 1...
View Full 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