Question 1
Consider the following function:
The function is called as:
How many recursive calls will be made by the function excluding the first main call?

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: 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:
The function is called as:
How many recursive calls will be made by the function excluding the first main call?
Correct answer: 4
In a binary tree, suppose there are: 14 nodes with two children, and• 6 nodes with exactly one child.• How many leaf nodes does the tree have?
Correct answer: 15
While inserting the elements 50, 80, 20, 60, 10, 45, 65, 30, and 90 into an empty binary search tree (BST) in the sequence shown, the sum of elements at maximum depth is____.
Correct answer: 95
How many bits will be used to encode the message ABCDE using Huffman codes?
Correct answer: 12
Correct answer: 10
Correct answer: 1500
Correct answer
None of these
Correct answer
Correct answer
Correct answer
Run DFS starting from vertex A. If multiple adjacent vertices exist, they are visited in alphabetical order.
Which of the following is the correct DFS traversal order?
A, B, D, E, C, F, G, H, I, J
A, B, C, H, J, G, D, E, F, I
A, B, C, H, J, G, E, D, F, I
A, B, C, D, E, F, G, H, I, J
Correct answer
A, B, C, H, J, G, D, E, F, I
Correct answer
33, 63
33, 127
7, 127
7, 63
Correct answer
33, 127
You are given the following list of 8 meeting requests with start time, and end time.
3
4
5
6
Correct answer
3
Correct answer
Correct answer
Correct answer
Which of the following could be possible insertion orders that produce the above hash table?
24, 35, 60, 48, 71, 14
60, 48, 71, 14, 24, 35
60, 48, 71, 24, 35, 14
24, 35, 71, 48, 60, 14
Correct answers
24, 35, 60, 48, 71, 14
60, 48, 71, 24, 35, 14
A data science bootcamp offers 6 learning modules. Students must complete modules according to the prerequisite structure shown below.
A valid completion order must satisfy all prerequisite constraints.
Which of the following can be valid orders in which the modules are completed?
1, 2, 3, 4, 5, 6
1, 3, 2, 4, 5, 6
1, 2, 4, 5, 3, 6
1, 3, 5, 2, 4, 6
Correct answers
1, 2, 3, 4, 5, 6
1, 3, 2, 4, 5, 6
Consider the following graph.
Suppose Dijkstra’s algorithm is executed with vertex 0 as the source vertex.
Which of the following is the correct order in which vertices are marked as visited by Dijkstra’s algorithm?
0, 2, 1, 3, 4, 5
0, 1, 2, 3, 5, 4
0, 2, 3, 1, 5, 4
0, 2, 1, 3, 5, 4
Correct answer
0, 2, 1, 3, 5, 4
Which of the following is/are always true about the Floyd-Warshall algorithm?
It works correctly if the graph has negative edge weights but does not have negative weight cycles.
Correct answers
It works correctly if the graph has negative edge weights but does not have negative weight cycles.
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 statements are correct?
The total weight of MST is 12
The number of distinct MSTs in the graph is 2
The edge (d, f) will be part of every MST
The edge (b, c) will be part of every MST
The edge (b, d) will be part of every MST
Correct answers
The total weight of MST is 12
The number of distinct MSTs in the graph is 2
The edge (d, f) will be part of every MST
Let C be a problem that belongs to the class NP. Which of the following statement(s) is/are TRUE?
If C is NP-Hard, then it is NP-complete.
There is no polynomial-time algorithm for C
If C can be solved in polynomial time, then P = NP.
If every problem in NP is reducible to C in polynomial time, then C is NP- complete.
Correct answers
If C is NP-Hard, then it is NP-complete.
If every problem in NP is reducible to C in polynomial time, then C is NP- complete.
Correct answer: 40