0% found this document useful (0 votes)
9 views2 pages

Cse2012 PPS5 w2022

The document discusses the rod cutting problem and provides 10 practice problems related to designing dynamic programming algorithms for variations of the rod cutting problem. The problems involve designing pseudocode to solve the basic rod cutting problem using top-down, bottom-up, and other strategies. They also involve modifications like restricting piece lengths, adding penalties, and solving for multiple number of pieces.

Uploaded by

Lazer Tron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Cse2012 PPS5 w2022

The document discusses the rod cutting problem and provides 10 practice problems related to designing dynamic programming algorithms for variations of the rod cutting problem. The problems involve designing pseudocode to solve the basic rod cutting problem using top-down, bottom-up, and other strategies. They also involve modifications like restricting piece lengths, adding penalties, and solving for multiple number of pieces.

Uploaded by

Lazer Tron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE 2012- Design and Analysis of Algorithms

Practice Problem Sheet (Dynamic Prograaming)


Rod-cutting Problem
Practice makes you Perfect

Rod Cutting Problem :


Given a rod of length n units and the price of a rod of length i units, pi ,
i = 1, 2, ..., n, task is to determine the maximum revenue rn obtainable by
cutting up the rod and selling the pieces. One can sell the rod of length n as
such (without any cutting) or one can cut the rod into small pieces and the sell
all the pieces at the respective prices given. One has to compute the best way
to cut the rod so that maximum revenue is obtained.

1. Describe the stages involved in the design of a dynamic programming


pseudocode for a problem. You are expected to take a problem (your
choice) and illustrate all the stages of the dynamic-programming-design
with the problem chosen by you. The problem chosen by you should be
different from the ones discussed in the class.

2. Given a problem P, Explain the required properties that has to be ex-


hibited in the probelm so that dynamic programming based pseudocode
is feasible for the problem P. In other words, you are expected to take a
problem (of your choice) and describe the ‘thought-process’ involved in
taking a decision ‘whether the problem (chosen by you) is solvable by a
dynamic-programming-pseudocode or not?’.
3. MyFibonacci series is one which is defined as follows:

f iba(1) = 0, f iba(2) = 1, f iba(3) = 2 f iba(n) = f iba(n−1)+f iba(n−2)+f iba(n−3)

Given n, design a pseudocode to compute f iba(n), using the dynamic-


programming ( top-down approach). Analyse your algorithm with the
required components.
4. Given a rod of length n, and price pi , i = 1, 2, ..., n, where pi is a rod of
length i units, design a brute-force algorithm to solve the ‘Rod Cutting
Problem’ described above. Your algorithm should return the maximum-
revenue that is obtainable by selling the rod of length n after cutting them
into smaller pieces. Anayse your algorithm with the required components.

1
5. Design a pseudocode to solve the ‘Rod Cutting Problem’ that uses the
dynamic programming strategy (top-down strategy). Your pseudocode
should return the maximum-revenue that is obtainable by selling the rod
of length n after cutting them into smaller pieces. Anayse your algorithm
with the required components.

6. Design a recursive pseudocode to solve the ‘Rod Cutting Problem’ that


uses the dynamic programming strategy (bottom-up strategy). Your pseu-
docode should return the maximum-revenue that is obtainable by selling
the rod of length n after cutting them into smaller pieces.
7. . Design a pseudocode to solve the ‘Rod Cutting Problem’. Given the
length of the rod n and the prices pi , your pseudocode should return the
maximum revenue along with the lengths of the smaller pieces (decompo-
sition of n) . You can follow any strategy for the purpose.
8. We modify the ‘Rod Cutting Problem’ as follows:

ˆ Length of the given rod is greater than or equal to 8.


ˆ You have to cut the rods in such a way that the length of smaller
piece is either of length 3 or of length 5.
ˆ If there is a wastage of rod (a piece whose is length is less than 3
cannot be cut further due to the restriction), there will be a penalty
of Re 1 for each unit length.
We call the above problem as ’Modified Rod cutting problem’. Design a
pseudocode that will return the maximum revenue that can be obtained by
selling the rod, given the length of the rod and the price pi , i = 1, 2, ..., n.
9. Given a rod of length n units, the price of a rod of length i units, pi ,
i = 1, 2, ..., n and another positive integer k(k ≤ n), Design a pseudocode
to compute the maximum-revenue that is obtainable by selling the rod of
length n after cutting them into k smaller pieces. For each possible value
of k, your code should return the maximum-revenue obtainable by selling
the k pieces. Analyse the algorithm with the required components.

10. Illustrate the differences between the Divide-Conquer-Combine strategy


and the dynamic programming strategy, by taking a problem (of your
choice)

You might also like