Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
bartleby

Concept explainers

Question
Book Icon
Chapter 15.1, Problem 2E
Program Plan Intro

To give a counter example so that the following greedy strategy does not always determine an optimal way to cut rods.

Blurred answer
Students have asked these similar questions
Exercise 4 20= 10+4+6 The rod-cutting problem consists of a rod of n units long that can be cut into integer-length pieces. The sale price of a piece i units long is Pi for i = 1,...,n. We want to apply dynamic programming to find the maximum total sale price of the rod. Let F(k) be the maximum price for a given rod of length k. 1. Give the recurrence on F(k) and its initial condition(s). 2. What are the time and space efficiencies of your algorithm? Now, consider the following instance of the rod-cutting problem: a rod of length n=5, and the following sale prices P1=2, P2=3, P3-7, P4=2 and P5=5.
Let's say there are n villages, {X1, . . . , Xn} on the country-road and we aim to build K < n restaurants to cover them. Each restaurant has to be built in a village, and we hope to minimize the average distance from each village to the closest restaurant. Please give an algorithm to compute the optimal way to place these K restaurants. The algorithm should run in O(k * n^2) time. Solutions with slightly higher time complexity also accepted.
An electrician has wired n lights, all initially on, so that: 1) light 1 can always be turned on/off, and 2) for k > 1, light k cannot be turned either on or off unless light k – 1 is on and all preceding lights are off for k > 1. The question we want to explore is the following: how many moves are required to turn all n lights off? For n = 5, a solution sequence has been worked out below. Fill in the missing entries. The lights are counted from left to right, so the first bit is the first light, and so on. 11111 01111 11011 10011 00010 10010 11010
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education