Hbs4 - 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

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

View Full Document Right Arrow Icon
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
Background image of page 1
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 efficient algorithm to compute the maximum revenue we can acquire by constructing billboards. 1...
View Full Document

This note was uploaded on 01/22/2011 for the course CS 473 taught by Professor Chekuri,c during the Fall '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online