Question
Define to be the maximum amount earned by cutting a rod of length meters into one or more pieces of integer length and selling them. For , let denote the selling price of a rod whose length is meters. Consider the array of prices:
Which of the following statements is/are correct about ?
Official answer and solution
- Official answer
- A and C
- From
- Official GATE 2021 answer key
Solution
Compute optimal revenue for rod lengths 1 through 7 using dynamic programming, and list all combinations that achieve the maximum.
The price array is: .
The dynamic programming recurrence is , with .
Compute bottom-up:
Thus (Statement A is correct, B is false).
Now find all partitions of 7 yielding revenue 18:
- Cut into 1 piece: .
- Cut into 2 pieces: .
- Cut into 3 pieces: .
No other partition achieves 18. Hence, is achieved by exactly three different solutions (Statement C is correct). Because solution consists of three pieces, Statement D is false.
Therefore, statements A and C are correct.
A, C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2021 Computer Science and Information Technology (CS, Set-1)
- Question
- 50 of 65, printed as CS Q.40
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.