chapter
    Programming, Data Structures and Algorithms Short Notes for GATE DA

    GATE DA Programming, Data Structures and Algorithms: 3 units and 13 chapters, weightage from 31 previous year questions across 3 papers, a study order by exam

    A question from this chapter

    Question 1
    Level 1: Warm-up

    Which of the following statements is true regarding list mutation and rebinding in Python?

    Question 2
    Level 1: Warm-up

    A recursive function f(n) contains a local variable x initialized to 0. If the initial call is f(3) and it makes recursive calls f(2), f(1), and f(0) in a single linear chain, how many distinct, isolated copies of the local variable x are created in total across all frames?

    Question 3
    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 4
    Level 1: Warm-up

    Which of the following statements about the None pattern for default arguments in Python is true?

    Question 5
    Level 1: Warm-up

    In a Stack data structure, the <code>Push</code> operation inserts a new element at which position?

    Question 6
    Level 1: Warm-up

    Match the operations with their corresponding expected number of probes for a hash table with load factor .

    List I (Operation):

    P. Unsuccessful Search

    Q. Insertion

    R. Successful Search

    List II (Formula):

    Question 7
    Level 1: Warm-up

    What is the minimum number of nodes a general binary tree must have so that its Pre-order and Post-order traversals are ambiguous (i.e., more than one valid tree can be constructed)?

    Question 8
    Level 1: Warm-up

    In a binary search implementation, each step checks if the middle element is equal to the target, and if not, checks if it is less than the target. For an array of size , which of the following statements is true regarding the maximum number of comparisons?

    Free preview ends here

    Login to view the complete short notes

    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.

    Programming, Data Structures and Algorithms Short Notes for GATE DA

    GATE DA Programming, Data Structures and Algorithms: 3 units and 13 chapters, weightage from 31 previous year questions across 3 papers, a study order by exam weight and 1678 practice questions.

    About Programming, Data Structures and Algorithms Short Notes

    Quick revision sheets for Programming, Data Structures and Algorithms in GATE DA. Every chapter is condensed into key formulas, shortcuts and common traps so you can revise 13 chapters fast before the exam.

    GATE DA Programming, Data Structures and Algorithms Unit-wise Weightage from Past Papers

    We counted every GATE DA Programming, Data Structures and Algorithms previous year question in our bank (31 questions from 3 papers) and grouped them by unit.

    UnitChaptersPYQsShare of sectionAvg per paper
    Programming Fundamentals4929%3
    Data Structures3826%2.7
    Algorithms61445%4.7

    Suggested Programming, Data Structures and Algorithms Study Order for GATE DA

    1. Algorithms: 45% of past Programming, Data Structures and Algorithms questions, about 4.7 per paper.
    2. Programming Fundamentals: 29% of past Programming, Data Structures and Algorithms questions, about 3 per paper.
    3. Data Structures: 26% of past Programming, Data Structures and Algorithms questions, about 2.7 per paper.

    Start where the marks are. Units at the top of this list have appeared most often in past GATE DA papers.

    Units in GATE DA Programming, Data Structures and Algorithms

    All Programming, Data Structures and Algorithms chapters

    One Solved Question from Each Programming, Data Structures and Algorithms Chapter

    Question 1 · Python Data Structures: Lists, Sets and Dictionaries MCQ

    Which of the following statements is true regarding list mutation and rebinding in Python?

    1. A.

      x = x + [4] mutates the existing list in place.

    2. B.

      x += [4] creates a new list and leaves the original unchanged.

    3. C.

      y = x creates a separate copy of the list.

    4. D.

      x.append(4) modifies the existing list, so all aliases see the change.

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: This is a statement truth question testing the boundary between mutation and rebinding.

    Step 1: Analyze Option A

    x = x + [4] uses the + operator, which creates a new list and rebinds x. It does not mutate. (False)

    Step 2: Analyze Option B

    x += [4] uses augmented assignment. For lists, this mutates the existing list in place. It does not create a new list. (False)

    Step 3: Analyze Option C

    y = x creates an alias, not a copy. Both point to the same object. (False)

    Step 4: Analyze Option D

    x.append(4) is a mutating method. It changes the existing list, so any other variable pointing to the same list (aliases) will see the change. (True)

    Answer: Option D

    Question 2 · Python Functions and Recursion MCQ

    A recursive function f(n) contains a local variable x initialized to 0. If the initial call is f(3) and it makes recursive calls f(2), f(1), and f(0) in a single linear chain, how many distinct, isolated copies of the local variable x are created in total across all frames?

    1. A.

      1

    2. B.

      3

    3. C.

      4

    4. D.

      5

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Every recursive call creates a new, isolated stack frame with its own local variables.

    Step 1: Identify the sequence of function calls: f(3), f(2), f(1), f(0).

    Step 2: Count the total number of function invocations in this chain. There are 4 calls in total.

    Step 3: Apply the mental model of stack frames. Each of the 4 calls creates a distinct stack frame.

    Step 4: Since x is a local variable initialized inside the function, a new, isolated copy of x is created in each of the 4 frames.

    Step 5: The total number of distinct copies is 4.

    Answer: C

    Question 3 · List Processing and In-Place Mutation 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 4 · Function Scope, Closures and Default Arguments MCQ

    Which of the following statements about the None pattern for default arguments in Python is true?

    1. A.

      None is evaluated at call time, bounding the state to each individual call.

    2. B.

      None is immutable, bounding the default to a safe, unchangeable reference.

    3. C.

      The None pattern requires the function to return None if the argument is missing.

    4. D.

      Using None as a default automatically creates a new list for each call without explicit checks.

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a statement truth question about the None pattern, recognizable by evaluating the properties of None and the pattern's mechanics.

    Step 1: Evaluate option A: "None is evaluated at call time" - False. All default arguments, including None, are evaluated at definition time.

    Step 2: Evaluate option B: "None is immutable, bounding the default to a safe, unchangeable reference" - True. None cannot be mutated in place, so it safely avoids the shared state trap.

    Step 3: Evaluate option C: "requires the function to return None" - False. The pattern dictates the default argument, not the return value.

    Step 4: Evaluate option D: "automatically creates a new list... without explicit checks" - False. Python does not automatically create objects; the programmer must explicitly write the <code>if lst is None: lst = []</code> check.

    Answer: B

    Question 5 · Stacks, Queues and Deques MCQ

    In a Stack data structure, the <code>Push</code> operation inserts a new element at which position?

    1. A.

      At the top of the stack

    2. B.

      At the bottom of the stack

    3. C.

      At the middle of the stack

    4. D.

      At a random position

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a definition recall question about the Push operation, recognizable because it asks where a new element is placed in a stack. Step 1: Recall that a stack follows the LIFO (Last In, First Out) principle. Step 2: To maintain LIFO order, new elements must be added at the same end from which they will be removed. This end is called the top. Step 3: Therefore, Push always inserts at the top of the stack. Answer: Option A
    Question 6 · Hash Tables and Collision Resolution MCQ

    Match the operations with their corresponding expected number of probes for a hash table with load factor .

    List I (Operation):

    P. Unsuccessful Search

    Q. Insertion

    R. Successful Search

    List II (Formula):

    1. A.

      P-1, Q-1, R-2

    2. B.

      P-1, Q-2, R-1

    3. C.

      P-2, Q-1, R-1

    4. D.

      P-1, Q-2, R-2

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a match-the-following question testing your ability to map hash table operations to their correct probe complexity formulas.

    Step 1: Unsuccessful Search (P). Probing until an empty slot is found. Formula: . Matches 1.

    Step 2: Insertion (Q). Probing until an empty slot is found to place the new element. This is identical to an unsuccessful search. Formula: . Matches 1.

    Step 3: Successful Search (R). Searching for a key already in the table. Formula: . Matches 2.

    Final mapping: P-1, Q-1, R-2.

    Common trap: A student might misread the condition for insertion and think it requires a successful search formula, matching Q with 2.

    Answer: P-1, Q-1, R-2

    Question 7 · Binary Trees: Properties and Traversals MCQ

    What is the minimum number of nodes a general binary tree must have so that its Pre-order and Post-order traversals are ambiguous (i.e., more than one valid tree can be constructed)?

    1. A.

      1

    2. B.

      2

    3. C.

      3

    4. D.

      4

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: Ambiguity in Pre-order and Post-order reconstruction occurs when a node has exactly one child, because the sequences cannot distinguish if it is a left or right child.

    Step 1: For a tree with 1 node, Pre-order and Post-order are identical and uniquely define the tree.

    Step 2: For a tree with 2 nodes (a root and one child), Pre-order is [Root, Child] and Post-order is [Child, Root]. The child could be either the left or right child of the root. This creates ambiguity.

    Step 3: Therefore, the minimum number of nodes required to create this ambiguity is 2.

    Answer: The minimum number of nodes is 2.

    Question 8 · Searching Algorithms and Binary Search MCQ

    In a binary search implementation, each step checks if the middle element is equal to the target, and if not, checks if it is less than the target. For an array of size , which of the following statements is true regarding the maximum number of comparisons?

    1. A.

      It is bounded by

    2. B.

      It is bounded by

    3. C.

      It is bounded by

    4. D.

      It is bounded by

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This tests the comparison counting trap based on code implementation.

    Step 1: Analyze the code logic. There are two comparisons per step: one for equality, one for less-than.

    Step 2: The depth of the tree is still .

    Step 3: Multiply the depth by the number of comparisons per step: .

    Answer: It is bounded by .