GATE / CS ARCHIVE

GATE CSE 2014 SET 3 / QUESTION 37

GATE CSE 2014 Set 3 Q37

Algorithms · Dynamic Programming · Full GATE CSE 2014 Set 3 paper

GATE 2014 Set 3, Q37 2 marks · NAT
Report issue

Dynamic Programming

Question 37, GATE 2014: Move from 0 to 100 on the number line. One step either moves from k to k+1 or takes a supplied shortcut (i,j), i<j, directly from i to j. At most one shortcut involves any number; in particular 9 has a shortcut to 15. T(k) is the minimum steps from k to 100. If T(9)=1+min(T(y),T(z)), find yz.
Tap to enlarge
Answer & solution

Official answer: 150

Step 1: Condition on the first move from 9. The ordinary unit move reaches 10; the available shortcut reaches 15. Each costs one step. Step 2: Once the first move is made, the optimal remaining cost is T(10) or T(15), so optimal substructure yields T(9)=1+min(T(10),T(15)). Step 3: The order of y and z is irrelevant: their product is 10×15=150. No knowledge of the remaining shortcuts is needed to identify these two immediate successor states.

Original paper, page 61 · Answer key