Programming, Data Structures and Algorithms Practice Questions 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 N, the single-index scan uses the base condition i >= len(L) - 1. What is the minimum value of N for which the function will execute at least one comparison (i.e., not immediately hit the base case at i=0)?
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):
1−α1
α1ln(1−α1)
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 N, which of the following statements is true regarding the maximum number of comparisons?
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.
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 Practice Questions 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 Practice Questions
1678 practice questions for Programming, Data Structures and Algorithms in GATE DA, sorted chapter by chapter and graded from basic to exam level, each with a full solution.
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.
One Solved Question from Each Programming, Data Structures and Algorithms Chapter
Question 1 · Python Data Structures: Lists, Sets and DictionariesMCQ
Which of the following statements is true regarding list mutation and rebinding in Python?
A.
x = x + [4] mutates the existing list in place.
B.
x += [4] creates a new list and leaves the original unchanged.
C.
y = x creates a separate copy of the list.
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 RecursionMCQ
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?
A.
1
B.
3
C.
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 MutationMCQ
For a list of length N, the single-index scan uses the base condition i >= len(L) - 1. What is the minimum value of N for which the function will execute at least one comparison (i.e., not immediately hit the base case at i=0)?
A.
0
B.
1
C.
2
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 N=1, len(L) - 1 = 0. At i=0, 0 >= 0 is true, so it hits the base case immediately without comparing.
Step 2: For N=2, len(L) - 1 = 1. At i=0, 0 >= 1 is false, so it proceeds to compare L[0] and L[1].
Answer: C
Question 4 · Function Scope, Closures and Default ArgumentsMCQ
Which of the following statements about the None pattern for default arguments in Python is true?
A.
None is evaluated at call time, bounding the state to each individual call.
B.
None is immutable, bounding the default to a safe, unchangeable reference.
C.
The None pattern requires the function to return None if the argument is missing.
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 DequesMCQ
In a Stack data structure, the <code>Push</code> operation inserts a new element at which position?
A.
At the top of the stack
B.
At the bottom of the stack
C.
At the middle of the stack
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 ResolutionMCQ
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−α1
α1ln(1−α1)
A.
P-1, Q-1, R-2
B.
P-1, Q-2, R-1
C.
P-2, Q-1, R-1
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: 1−α1. 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: 1−α1. Matches 1.
Step 3: Successful Search (R). Searching for a key already in the table. Formula: α1ln(1−α1). 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 TraversalsMCQ
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)?
A.
1
B.
2
C.
3
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 SearchMCQ
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 N, which of the following statements is true regarding the maximum number of comparisons?
A.
It is bounded by ⌊log2Nfloor+1
B.
It is bounded by 2⌊log2Nfloor+2
C.
It is bounded by ⌈log2Nceil
D.
It is bounded by 2⌈log2Nceil
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 ⌊log2N⌋+1.
Step 3: Multiply the depth by the number of comparisons per step: 2×(⌊log2N⌋+1)=2⌊log2N⌋+2.