GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 34

Maximum weighted subsequence recurrence

Algorithms · Dynamic Programming · Full GATE CSE 2010 paper

GATE 2010, Q34 2 marks · MCQ
Report issue

Dynamic Programming

Question 34, GATE 2010: The weight of a real sequence a₀,…,aₙ₋₁ is a₀+a₁/2+⋯+aₙ₋₁/2^(n−1). A subsequence deletes elements without changing the order. X is the maximum subsequence weight of a₀,…,aₙ₋₁ and Y is that of a₁,…,aₙ₋₁. What is X?
Options: (A) max(Y,a₀+Y); (B) max(Y,a₀+Y/2); (C) max(Y,a₀+2Y); (D) a₀+Y/2.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Split subsequences according to whether they include a₀. If not, their optimum weight is Y, the optimum on the suffix. If they do, a₀ contributes with weight 1 and each selected suffix element shifts one position, halving its contribution; the best such weight is a₀+Y/2. Thus X=max(Y,a₀+Y/2), B. The usual subsequence convention permits the empty subsequence, ensuring this also works with negative inputs.

The split is exhaustive and disjoint: every candidate either omits a₀ or contains it. Including a₀ shifts every chosen suffix element one weight position to the right, multiplying the entire suffix weight by 1/2; its internal order and relative weights are unchanged. Since 1/2 is positive, the suffix maximizing its own weight also maximizes the scaled weight. The outer maximum is necessary because including a negative a₀ can be harmful.

Original paper, page 8