Question 1
Consider the following function:

The IIT Madras BS Programming, Data Structures and Algorithms using Python (PDSA) End Term paper sat on 10 May 2026, in the January 2026 term, set 1-2: 24 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Consider the following function:
Correct answer: 6
In a binary tree, the total number of nodes is 28. It is known that 10 nodes have exactly two children.
How many nodes have exactly one child?
Correct answer: 7
While inserting the elements 60, 30, 50, 55, 80, 90, 65, 70, and 10 into an empty binary search tree (BST) in the sequence shown, the sum of elements at maximum depth is __.
Correct answer: 125
How many bits will be used to encode the message ABCDE using Huffman codes?
Correct answer: 13
Correct answer: 9
Correct answer
Correct answer
Correct answer
Correct answer
Run BFS starting from vertex A. If multiple adjacent vertices exist, they are visited in alphabetical order.
Which of the following is the correct BFS traversal order?
A, B, D, E, C, F, G, H, I, J
A, B, D, E, F, C, G, H, I, J
A, B, C, H, J, G, D, E, F, I
A, B, D, E, C, F, H, G, I, J
Correct answer
A, B, D, E, C, F, G, H, I, J
Correct answer
The Bellman-Ford algorithm cannot be used if a graph has negative cycles. This is because:
The algorithm only runs for n iterations, where n is the number of vertices.
The notion of the shortest path is not well-defined if there are negative cycles.
Dealing with negative cycles requires examining all paths exhaustively, which takes exponential time.
To handle negative cycles, we need to compute all-pairs shortest paths.
Correct answer
The notion of the shortest path is not well-defined if there are negative cycles.
While inserting the elements 8, 4, 1, 3, 9, 2, and 11 in an empty AVL tree in the given sequence, the leaf elements are__.
1, 3, 8, 11
1, 3, 9, 11
2, 3, 9, 11
1, 2, 8, 11
Correct answer
1, 3, 8, 11
2
3
4
5
Correct answer
4
Correct answer
Correct answer
Correct answer
Correct answer
Let G be a simple graph with 25 vertices and 50 edges. The size of the minimum vertex cover of G is 10. What is the size of the maximum independent set of G ?
65
90
15
35
Correct answer
15
Which of the following could be possible insertion orders that produce this table?
21, 32, 27, 12, 31, 40, 25
21, 32, 27, 12, 25, 31, 40
40, 32, 21, 25, 31, 12, 17
40, 32, 21, 25, 31, 27, 12
Correct answers
21, 32, 27, 12, 31, 40, 25
40, 32, 21, 25, 31, 27, 12
A technology training institute offers an advanced certification program consisting of 10 modules. The program is divided into terms of 4 months.
Students may enroll in any number of modules in a term, but a module can only be taken after completing all of its prerequisite modules.
The prerequisite structure is given below.
There is no restriction on the number of modules a student can take in a term.
The minimum number of terms required to complete all 10 modules is ___.
Correct answer: 6
Correct answer: 26
Consider the following graph.
Which of the following options correctly represents the shortest distances from node 0 to nodes (1, 2, 3, 4, 5) respectively?
3, 2, 5, 9, 8
4, 2, 6, 9, 8
3, 2, 5, 8, 7
3, 2, 5, 7, 8
Correct answer
3, 2, 5, 8, 7
Consider the graph G given below.
Let Minimum Spanning Trees (MSTs) of the graph be constructed using algorithms such as Kruskal’s or Prim’s algorithm.
Which of the following statement(s) is/are correct?
The total weight of every MST is 10
The total weight of every MST is 11
The edge (d, e) will not be part of any MST
The edge (b, e) will be part of every MST
The number of distinct MSTs in the graph is 2
Correct answers
The total weight of every MST is 10
The edge (d, e) will not be part of any MST
The edge (b, e) will be part of every MST