chapter
    List Processing and In-Place Mutation Practice Questions for GATE DA

    Solve 103+ List Processing and In-Place Mutation 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

    For a list of length , the single-index scan uses the base condition i >= len(L) - 1. What is the minimum value of for which the function will execute at least one comparison (i.e., not immediately hit the base case at )?

    Question 2
    Level 1: Warm-up

    For a list of length 5, what is the minimum number of recursive calls (including the initial call and the base case call) made by the scan function before it terminates, regardless of the list's initial order?

    Question 3
    Level 1: Warm-up

    For a list of length , the single-index scan pattern compares adjacent elements. What is the exact number of comparisons performed during a single pass, regardless of the initial order of the list?

    Question 4
    Level 1: Warm-up

    If the single-index recursive scan is called on a list of length 1, what is the minimum number of swaps it can perform before hitting the base case?

    Question 5
    Level 1: Warm-up

    The single-index scan uses the base condition i >= len(L) - 1. A student argues that for an empty list, the expression len(L) - 1 must evaluate to a minimum of 0 because list indices cannot be negative. What is the actual value of len(L) - 1 for an empty list, which contradicts this assumption?

    Question 6
    Level 1: Warm-up

    Consider the adjacent-swap recursive scan on a list. Which of the following statements is true regarding the movement of elements during a single pass?

    Question 7
    Level 1: Warm-up

    Assertion (A): In a recursive scan that counts swaps, the base case returns 0, and each swap adds 1 to the result of the next recursive call.

    Reason (R): This aggregation correctly counts the total number of swaps because the function creates a new list at each step to keep track of the count.

    Question 8
    Level 1: Warm-up

    Which of the following statements is true regarding the base condition of the adjacent-swap recursive scan for a list of length ?

    Question 9
    Level 1: Warm-up

    Assertion (A): In the return aggregation pattern, a swap adds 1 to the result of the next recursive call.

    Reason (R): This correctly computes the total number of elements in the list.

    Question 10
    Level 1: Warm-up

    Assertion (A): The return value of the recursive scan is built by adding 1 for each swap and passing the result forward when no swap occurs.

    Reason (R): This aggregation mechanism correctly computes the total number of inversions in the original unsorted list.

    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.

    List Processing and In-Place Mutation Practice Questions for GATE DA

    Solve 103+ List Processing and In-Place Mutation practice questions for GATE DA with answers and detailed solutions. Free sample questions below.

    Chapter Roadmap: List Processing and In-Place Mutation

    Chapter Roadmap

    Chapter journey

    1. Recursive List Processing and In-Place Mutation
      Current topic. High-importance tracing.
      • Single-index recursive scans
      • Adjacent-swap counting
      • Two-pointer reversal
    2. Chapter mastery
      • Track exact list state after every swap
      • Decide if call is scan or reversal
      • Predict final return value and list
    Weight hint: Core tracing topic. Small code pieces can carry good marks through careful step-by-step execution.

    Topic Hero: Recursion Meets Mutable Lists

    Topic Hero: Recursion Meets Mutable Lists

    A Python list is mutable. If a recursive function changes the list, the changed list is visible to all deeper recursive calls.

    Two core shapes appear repeatedly:

    Shape Indices used Typical operation
    Single-index scan i Compare and possibly swap L[i] and L[i+1]
    Two-pointer reversal s1, s2 Swap D[s1] and D[s2], then move inward
    Key idea: The list is shared, but the index variables are local to each recursive call.

    List Processing and In-Place Mutation: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Programming, Data Structures and Algorithms MCQ

    For a list of length , the single-index scan uses the base condition i >= len(L) - 1. What is the minimum value of for which the function will execute at least one comparison (i.e., not immediately hit the base case at )?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. D.

      3

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: The base condition prevents accessing out-of-bounds indices.

    Step 1: The condition is i >= len(L) - 1. For , len(L) - 1 = 0. At , 0 >= 0 is true, so it hits the base case immediately without comparing.

    Step 2: For , len(L) - 1 = 1. At , 0 >= 1 is false, so it proceeds to compare and .

    Answer: C

    Question 2 · Programming, Data Structures and Algorithms MCQ

    For a list of length 5, what is the minimum number of recursive calls (including the initial call and the base case call) made by the scan function before it terminates, regardless of the list's initial order?

    1. A.

      4

    2. B.

      5

    3. C.

      6

    4. D.

      7

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: The single-index scan always increments the index by 1 until it hits the base case.

    Step 1: For a list of length , the valid indices for comparison are 0, 1, 2, 3.

    Step 2: The base case triggers when , which means .

    Step 3: The function is called with , and finally (which hits the base case).

    Step 4: This results in exactly 5 calls.

    Answer: B

    Question 3 · Programming, Data Structures and Algorithms MCQ

    For a list of length , the single-index scan pattern compares adjacent elements. What is the exact number of comparisons performed during a single pass, regardless of the initial order of the list?

    1. A.

    2. B.

    3. C.

    4. D.

      0

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: The scan compares and for each valid index .

    Step 1: The valid indices for comparison are .

    Step 2: The number of such indices is .

    Step 3: Therefore, exactly comparisons are performed in every pass.

    Answer: B

    Question 4 · Programming, Data Structures and Algorithms MCQ

    If the single-index recursive scan is called on a list of length 1, what is the minimum number of swaps it can perform before hitting the base case?

    1. A.

      1

    2. B.

      2

    3. C.

      3

    4. D.

      0

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: The base condition prevents any comparisons or swaps on lists that are too short.

    Step 1: For a list of length , the base condition is i >= len(L) - 1.

    Step 2: At the initial call, . The condition becomes 0 >= 1 - 1, which is 0 >= 0.

    Step 3: This condition is True, so the function immediately hits the base case and returns 0 without performing any comparisons or swaps.

    Answer: D

    Question 5 · Programming, Data Structures and Algorithms MCQ

    The single-index scan uses the base condition i >= len(L) - 1. A student argues that for an empty list, the expression len(L) - 1 must evaluate to a minimum of 0 because list indices cannot be negative. What is the actual value of len(L) - 1 for an empty list, which contradicts this assumption?

    1. A.

      -2

    2. B.

      -1

    3. C.

      0

    4. D.

      1

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: The length of an empty list is 0, and the base condition expression evaluates mathematically regardless of index validity.

    Step 1: For an empty list, len(L) = 0.

    Step 2: Substitute this into the expression len(L) - 1.

    Step 3: The calculation is 0 - 1 = -1.

    Step 4: The value is -1, which contradicts the student's assumption that it must be at least 0.

    Answer: B

    Question 6 · Programming, Data Structures and Algorithms MCQ

    Consider the adjacent-swap recursive scan on a list. Which of the following statements is true regarding the movement of elements during a single pass?

    1. A.

      Every element moves to its correct sorted position.

    2. B.

      A large element can move right multiple positions, but a small element moves left by at most one position.

    3. C.

      The list is guaranteed to be fully sorted after one pass.

    4. D.

      Elements only move left, never right.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: A single pass of adjacent swaps only moves elements one step in the "hard" direction.

    Step 1: During a left-to-right pass, a large element can be swapped multiple times, moving right by many positions.

    Step 2: However, a small element can only be swapped once when the large element passes it, moving left by at most one position.

    Answer: B

    Question 7 · Programming, Data Structures and Algorithms MCQ

    Assertion (A): In a recursive scan that counts swaps, the base case returns 0, and each swap adds 1 to the result of the next recursive call.

    Reason (R): This aggregation correctly counts the total number of swaps because the function creates a new list at each step to keep track of the count.

    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: Recursive counting aggregates the number of swaps without creating new data structures.

    Step 1: The assertion correctly describes the aggregation pattern: base case 0, add 1 for each swap.

    Step 2: The reason claims a new list is created at each step. This is false; the list is mutated in-place, and the count is returned via the call stack.

    Answer: C

    Question 8 · Programming, Data Structures and Algorithms MCQ

    Which of the following statements is true regarding the base condition of the adjacent-swap recursive scan for a list of length ?

    1. A.

      It triggers when the index reaches .

    2. B.

      It triggers when the index reaches .

    3. C.

      It triggers when the index reaches .

    4. D.

      It triggers when the list is fully sorted.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: The base condition prevents out-of-bounds access when comparing adjacent elements.

    Step 1: The scan compares and .

    Step 2: For a list of length , the highest valid index is .

    Step 3: To safely access , must be at most .

    Step 4: Therefore, the recursion must stop (base condition triggers) when reaches .

    Answer: B

    Question 9 · Programming, Data Structures and Algorithms MCQ

    Assertion (A): In the return aggregation pattern, a swap adds 1 to the result of the next recursive call.

    Reason (R): This correctly computes the total number of elements in the list.

    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: The return aggregation pattern counts specific events, not list properties.

    Step 1: Evaluate Assertion (A). The pattern correctly adds 1 for each swap. This is true.

    Step 2: Evaluate Reason (R). The aggregation counts the number of swaps, not the total number of elements in the list. This is false.

    Answer: C

    Question 10 · Programming, Data Structures and Algorithms MCQ

    Assertion (A): The return value of the recursive scan is built by adding 1 for each swap and passing the result forward when no swap occurs.

    Reason (R): This aggregation mechanism correctly computes the total number of inversions in the original unsorted list.

    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: The return aggregation counts specific events during the traversal.

    Step 1: Evaluate Assertion (A). The pattern correctly adds 1 for each swap. This is true.

    Step 2: Evaluate Reason (R). The aggregation counts the number of swaps performed in one pass, not the total number of inversions in the original list. This is false.

    Answer: C

    More practice questions in this unit