What is an optimal solution to the fractional

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nction of the size of the input. It is common to refer to an algorithm such as our knapsack dynamic programming algorithm as being a pseudo-polynomial time algorithm, for its running time depends on the magnitude of a number given in the input, not its encoding size. In practice, such algorithms should run much faster than any brute-force algorithm, but it is not correct to say they are true polynomial-time algorithms. In fact, there is a theory known as NP-completeness, which is discussed in Chapter 13, that states that it is very unlikely that anyone will ever find a true polynomial-time algorithm for the 0-1 knapsack problem. Elsewhere in this book, we give additional applications of the dynamic programming technique for computing reachability in a directed graph (Section 6.4.2) and for testing the similarity of two strings (Section 9.4). Chapter 5. Fundamental Techniques 282 5.4 Exercises Reinforcement R-5.1 Let S = {a, b, c, d , e, f , g} be a collection of objects with benefit-weight values as follows: a: (12, 4), b: (10, 6), c: (8, 5), d : (11, 7), e: (14, 3), f : (7, 1), g: (9, 6). What is an optimal solution to the fractional knapsack problem for S assuming we have a sack that can hold objects with total weight 18? Show your work. R-5.2 Describe how to implement the TaskSchedule method to run in O(n log n) time. R-5.3 Suppose we are given a set of tasks specified by pairs of the start times and finish times as T = {(1, 2), (1, 3), (1, 4), (2, 5), (3, 7), (4, 9), (5, 6), (6, 8), (7, 9)}. Solve the task scheduling problem for this set of tasks. R-5.4 Characterize each of the following recurrence equations using the master method (assuming that T (n) = c for n < d , for constants c > 0 and d ≥ 1). a. T (n) = 2T (n/2) + log n b. T (n) = 8T (n/2) + n2 c. T (n) = 16T (n/2) + (n log n)4 d. T (n) = 7T (n/3) + n e. T (n) = 9T (n/3) + n3 log n R-5.5 Use the divide-and-conquer algorithm, from Section 5.2.2, to compute 10110011 · 10111010 in binary. Show your work. R-5.6 Use Strassen’s matrix multiplication algorithm to multiply the matrices X= 3 4 2 8 and Y= 15 96 . √ R-5.7 A complex number a + bi, where i = −1, can be represented by the pair (a, b). Describe a method performing only three real-number multiplications to compute the pair (e, f ) representing the product of a + bi and c + d i. R-5.8 Boolean matrices are matrices such that each entry is 0 or 1, and matrix multiplication is performed by using AND for · and OR for +. Suppose we are given two n × n random Boolean matrices A and B, so that the probability that any entry in either is 1, is 1/k. Show that if k is a constant, then there is an algorithm for multiplying A and B whose expected running time is O(n2 ). What if k is n? R-5.9 What is the best way to multiply a chain of matrices with dimensions that are 10 × 5, 5 × 2, 2 × 20, 20 × 12, 12 × 4, and 4 × 60? Show your work. R-5.10 Design an efficient algorithm for the matrix chain multiplication problem that outputs a fully parenthesized expression for how to multiply the matrices in the chain using the minimum number of operations. R-5.11 Solve Exercise R-5.1 for the 0-1 knapsack problem. R-5.12 Sally is hosting an Internet auction to sell n widgets. She receives m bids, each of the form “I want ki widgets for di dollars,” for i = 1, 2, . . . , m. Characterize her optimization problem as a knapsack problem. Under what conditions is this a 0-1 versus fractional problem? 5.4. Exercises 283 Creativity C-5.1 A native Australian named Anatjari wishes to cross a desert carrying only a single water bottle. He has a map that marks all the watering holes along the way. Assuming he can walk k miles on one bottle of water, design an efficient algorithm for determining where Anatjari should refill his bottle in order to make as few stops as possible. Argue why your algorithm is correct. C-5.2 Consider the single machine scheduling problem where we are given a set T of tasks specified by their start times and finish times, as in the task scheduling problem, except now we have only one machine and we wish to maximize the number of tasks that this single machine performs. Design a greedy algorithm for this single machine scheduling problem and show that it is correct. What is the running time of this algorithm? C-5.3 Describe an efficient greedy algorithm for making change for a specified value using a minimum number of coins, assuming there are four denominations of coins (called quarters, dimes, nickels, and pennies), with values 25, 10, 5, and 1, respectively. Argue why your algorithm is correct. C-5.4 Give an example set of denominations of coins so that a greedy change making algorithm will not use the minimum number of coins. C-5.5 In the art gallery guarding problem we are given a line L that represents a long hallway in an art gallery. We are also given a set X = {x0 , x1 , . . . , xn−1 } of real numbers that specify the positions of paintings in this hallway. Suppose that a single g...
View Full Document

This document was uploaded on 03/26/2014.

Ask a homework question - tutors are online