chapter
    Dynamic Programming and Sequence Processing Practice Questions for GATE DA

    Solve 55+ Dynamic Programming and Sequence Processing practice questions for GATE DA with answers and detailed solutions. Free sample questions below.

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    Level 1: Warm-up

    In the recurrence relation for the longest non-decreasing contiguous subarray, when the condition is satisfied, the update rule is . What is the minimum possible value of in this case?

    Question 2
    Level 1: Warm-up

    Consider the standard recurrence relation for finding the longest non-decreasing contiguous subarray, where represents the length of the valid segment ending exactly at index . If the condition is false (i.e., ), what is the minimum possible value of ?

    Question 3
    Level 1: Warm-up

    For the array , the DP array for the longest non-decreasing contiguous subarray is computed. Which of the following statements about is true?

    Question 4
    Level 1: Warm-up

    Given the DP array for a longest non-decreasing contiguous subarray problem, how many times does the segment reset (i.e., for )?

    Question 5
    Level 1: Warm-up

    For the array , the DP array for the longest non-decreasing contiguous subarray is computed. Which ONE of the following statements about is true?

    Question 6
    Level 1: Warm-up

    Given the DP array for a longest non-decreasing contiguous subarray problem, how many indices (where ) satisfy ?

    Question 7
    Level 1: Warm-up

    For a longest non-decreasing contiguous subarray problem on an array of length 5, which ONE of the following DP arrays is impossible?

    Question 8
    Level 1: Warm-up

    Consider the standard DP recurrence for the longest non-decreasing contiguous subarray, where denotes the length of the valid segment ending exactly at index . For an arbitrary array of length , what is the minimum possible value of ?

    Question 9
    Level 1: Warm-up
    Consider the following two statements about the longest non-decreasing contiguous subarray problem: Assertion (A): For the array , the length of the longest non-decreasing contiguous subarray is 4. Reason (R): The condition for a non-decreasing sequence is (strictly less than). Which of the following is correct?
    Question 10
    Level 1: Warm-up
    Match the arrays in List I with the length of their longest strictly increasing contiguous subarray in List II: List I: P. Q. R. S. List II: 1. 1 2. 2 3. 3
    Free preview ends here

    Login to view the complete practice questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Dynamic Programming and Sequence Processing Practice Questions for GATE DA

    Solve 55+ Dynamic Programming and Sequence Processing practice questions for GATE DA with answers and detailed solutions. Free sample questions below.

    Chapter Roadmap: Dynamic Programming and Sequence Processing

    Chapter Roadmap

    Your journey to mastering sequence-based dynamic programming.

    1. Consecutive Sequence Lengths

    Finding the longest contiguous subarray satisfying a condition.

    2. Subsequence Lengths

    Tackling non-contiguous sequences like LIS and LCS.

    3. Advanced Variations

    Matrix chain multiplication, edit distance, and complex states.

    What you will master

    • Defining precise DP states for sequence problems.
    • Formulating correct recurrence relations.
    • Optimizing space complexity from to .
    • Avoiding common traps in boundary conditions.

    Topic Hero: Dynamic Programming for Consecutive Sequence Lengths

    Topic Hero: Consecutive Sequence Lengths

    Focuses on finding the longest contiguous segment that satisfies a specific condition.

    Extend

    If condition met with previous element, add to previous segment.

    Reset

    If condition broken, start a new segment of length .

    This local decision builds a global solution in time.

    Dynamic Programming and Sequence Processing: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Programming, Data Structures and Algorithms MCQ

    In the recurrence relation for the longest non-decreasing contiguous subarray, when the condition is satisfied, the update rule is . What is the minimum possible value of in this case?

    1. A.

      0

    2. B.

      S[i-1]

    3. C.

      2

    4. D.

      1

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a direct recall question about the extend case of the recurrence relation.

    Step 1: When the condition is true, the recurrence gives .

    Step 2: The minimum possible value of any is 1 (the base case). So the minimum value of is 1.

    Step 3: Substituting: minimum .

    Answer: C (2)

    Question 2 · Programming, Data Structures and Algorithms MCQ

    Consider the standard recurrence relation for finding the longest non-decreasing contiguous subarray, where represents the length of the valid segment ending exactly at index . If the condition is false (i.e., ), what is the minimum possible value of ?

    1. A.

      0

    2. B.

      1

    3. C.

      S[i-1]

    4. D.

      S[i-1] - 1

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a direct recall question about the reset condition in the consecutive sequence DP recurrence.

    Step 1: Recall the recurrence relation. For each index , we initialize . Then we check if .

    Step 2: If the condition is true, we extend: .

    Step 3: If the condition is false (), the segment breaks. We do not extend. The value remains at its initialized value of 1.

    Step 4: Therefore, when , the minimum (and only) possible value of is 1.

    Answer: B (1)

    Question 3 · Programming, Data Structures and Algorithms MCQ

    For the array , the DP array for the longest non-decreasing contiguous subarray is computed. Which of the following statements about is true?

    1. A.

      S[3] = 2

    2. B.

      S[5] = S[4]

    3. C.

      S[4] \le S[3] + 1

    4. D.

      S[2] = 3

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a tracing question that tests your understanding of the bounding property .

    Step 1: Trace the DP array for .

    • : . Base case. .
    • : . Check: ? True. .
    • : . Check: ? False. .
    • : . Check: ? True. .
    • : . Check: ? True. .

    So .

    Step 2: Check each option.

    • A: ? No, .
    • B: ? No, .
    • C: ? . Yes, this is true.
    • D: ? No, .

    Answer: C

    Question 4 · Programming, Data Structures and Algorithms MCQ

    Given the DP array for a longest non-decreasing contiguous subarray problem, how many times does the segment reset (i.e., for )?

    1. A.

      2

    2. B.

      1

    3. C.

      3

    4. D.

      4

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a reverse-engineering question that tests your understanding of the DP array and the reset condition.

    Step 1: Understand what a "reset" means.

    • A reset occurs when for .
    • This happens when the condition is false.
    • Note: is the base case, not a reset.

    Step 2: Count the resets in .

    • : . Base case, not a reset.
    • : . This is a reset (since ).
    • : . Not a reset.
    • : . This is a reset.
    • : . Not a reset.

    Step 3: Count the resets.

    • Resets occur at and .
    • Total resets = 2.

    Answer: A (2)

    Question 5 · Programming, Data Structures and Algorithms MCQ

    For the array , the DP array for the longest non-decreasing contiguous subarray is computed. Which ONE of the following statements about is true?

    1. A.

      S[3] = 3

    2. B.

      S[4] = 2

    3. C.

      S[2] = 2

    4. D.

      S[5] = S[3]

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: This is a statement evaluation question requiring you to trace the DP array and check each claim.

    Step 1: Trace for using the non-decreasing condition .

    • : Base case. .
    • : ? False. Reset. .
    • : ? True. Extend. .
    • : ? False. Reset. .
    • : ? True. Extend. .
    • .

    Step 2: Check each option.

    • A: ? No, .
    • B: ? No, .
    • C: ? No, .
    • D: ? Yes, both equal 2.

    Answer: D

    Question 6 · Programming, Data Structures and Algorithms MCQ

    Given the DP array for a longest non-decreasing contiguous subarray problem, how many indices (where ) satisfy ?

    1. A.

      2

    2. B.

      4

    3. C.

      3

    4. D.

      5

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a direct counting question on a given DP array. Check each position.

    Step 1: List the values of :

    Step 2: Check for each :

    • : ? No.
    • : ? Yes.
    • : ? Yes.
    • : ? No.
    • : ? Yes.

    Step 3: Count the indices where : indices 2, 3, and 5. That is 3 indices.

    Answer: C (3)

    Question 7 · Programming, Data Structures and Algorithms MCQ

    For a longest non-decreasing contiguous subarray problem on an array of length 5, which ONE of the following DP arrays is impossible?

    1. A.

      S = [1, 1, 2, 3, 1]

    2. B.

      S = [1, 2, 1, 2, 1]

    3. C.

      S = [1, 2, 3, 1, 2]

    4. D.

      S = [1, 2, 3, 5, 1]

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: This is a feasibility check question. The recurrence relation imposes the constraint for all .

    Step 1: Recall why this constraint holds. At each step, is either reset to 1 or extended to . In both cases, .

    Step 2: Check each option against this constraint.

    • A: . Check: ok, ok, ok, ok. Valid.
    • B: . Check: ok, ok, ok, ok. Valid.
    • C: . Check: ok, ok, ok, ok. Valid.
    • D: . Check: ok, ok, ? No! . Violation at .

    Step 3: Option D violates the constraint, so it is impossible.

    Answer: D

    Question 8 · Programming, Data Structures and Algorithms MCQ

    Consider the standard DP recurrence for the longest non-decreasing contiguous subarray, where denotes the length of the valid segment ending exactly at index . For an arbitrary array of length , what is the minimum possible value of ?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. D.

      N

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a boundary condition question testing the reset mechanism of the recurrence relation.

    Step 1: Recall the recurrence. For each index , is initialized to 1. If the condition holds, becomes . Otherwise, it remains 1.

    Step 2: The question asks for the minimum possible value of for an array of length .

    Step 3: Can be 0? No, because the recurrence explicitly initializes before checking the condition, and the value only increases.

    Step 4: Can be 1? Yes. If the last two elements are strictly decreasing (i.e., ), the condition fails. The segment resets, and remains at its initialized value of 1. For example, if , then , so .

    Step 5: Therefore, the minimum possible value of is 1.

    Answer: B (1)

    Question 9 · Programming, Data Structures and Algorithms MCQ
    Consider the following two statements about the longest non-decreasing contiguous subarray problem: Assertion (A): For the array , the length of the longest non-decreasing contiguous subarray is 4. Reason (R): The condition for a non-decreasing sequence is (strictly less than). Which of the following is correct?
    1. A.

      Both A and R are true, and R is the correct explanation of A

    2. B.

      Both A and R are true, but R is NOT the correct explanation of A

    3. C.

      A is true, but R is false

    4. D.

      A is false, but R is true

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is an assertion-reason question testing your understanding of the non-decreasing condition.

    Step 1: Evaluate Assertion (A).

    • For , trace the DP array.
    • .
    • : ? True. .
    • : ? True. .
    • : ? True. .
    • Maximum is 4. So A is true.

    Step 2: Evaluate Reason (R).

    • R states the condition is (strictly less than).
    • However, "non-decreasing" means (less than or equal to).
    • The condition in R is for "strictly increasing", not "non-decreasing".
    • So R is false.

    Step 3: Conclusion.

    • A is true, but R is false.

    Answer: C

    Question 10 · Programming, Data Structures and Algorithms MCQ
    Match the arrays in List I with the length of their longest strictly increasing contiguous subarray in List II: List I: P. Q. R. S. List II: 1. 1 2. 2 3. 3
    1. A.

      P-2, Q-3, R-1, S-2

    2. B.

      P-1, Q-3, R-1, S-2

    3. C.

      P-2, Q-3, R-1, S-1

    4. D.

      P-2, Q-2, R-1, S-3

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a match-the-following question testing the trap of confusing strictly increasing with non-decreasing.

    Step 1: Trace each array for strictly increasing ().

    • P:
    • .
    • : ? False. .
    • : ? True. .
    • Max = 2. So P-2.
    • Q:
    • . Max = 3. So Q-3.
    • R:
    • . Max = 1. So R-1.
    • S:
    • .
    • : ? False. .
    • : ? True. .
    • Max = 2. So S-2.

    Step 2: Match: P-2, Q-3, R-1, S-2.

    Answer: A

    More practice questions in this unit