Question 1
What does the function f(1000,2) return?

The IIT Madras BS Programming, Data Structures and Algorithms using Python (PDSA) End Term paper sat on 13 Sept 2026, in the May 2026 term: 25 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.
What does the function f(1000,2) return?
Correct answer: 10
Consider the following implementation for Queue
Correct answer: 31
What is the total weight of the Minimum Spanning Tree (MST) of this graph?
Correct answer: 12
Correct answer: 15
Correct answer: 7
Correct answer: 12
Inscript Consider the following grid.
Correct answer: 18
Correct answer: 17
(i), (ii) and (iii) are all not true.
(ii) and (iii) are true but (i) is not true.
(ii) is true but (i) and (iii) are not true.
(i) and (ii) are true but (iii) is not true.
Correct answer
(ii) and (iii) are true but (i) is not true.
Correct answer
Index 0: 35, Index 1: 21, Index 2: 14
Index 0: 14, Index 1: 21, Index 2: 35
Index 0: 14, Index 1: 21, Index 4: 35
Index 0: 14, Index 4: 21, Index 1: 35
Correct answer
Index 0: 14, Index 1: 21, Index 4: 35
Graph G cannot exist because a vertex of degree 5 must be adjacent to every other vertex, which contradicts the presence of a vertex of degree 0.
Correct answer
Graph G cannot exist because a vertex of degree 5 must be adjacent to every other vertex, which contradicts the presence of a vertex of degree 0.
Suppose we run the Bellman-Ford algorithm on a directed graph where every edge weight is strictly positive. Which of the following statements accurately describes the behavior of the algorithm?
The algorithm will produce incorrect results because it is exclusively designed to process negative edge weights.
The algorithm will correctly find the shortest paths; however, its worst-case time complexity is higher than that of Dijkstra's algorithm for graphs with non-negative edge weights.
The algorithm will terminate early after exactly 1 iteration because positive edge graphs do not require path relaxation.
The algorithm will flag the graph as containing a negative cycle because it expects at least one negative edge value.
Correct answer
The algorithm will correctly find the shortest paths; however, its worst-case time complexity is higher than that of Dijkstra's algorithm for graphs with non-negative edge weights.
24
49
50
51
Correct answer
49
[5, 10, 15, 25, 50, 30, 40, 12]
[5, 25, 10, 40, 50, 30, 15, 12]
[5, 10, 15, 40, 50, 30, 12, 25]
[5, 10, 12, 25, 50, 30, 15, 40]
Correct answer
[5, 10, 12, 25, 50, 30, 15, 40]
Suppose the letters {A, B, C, D, E} occur with the following frequencies.
How many bits will be used to encode the letter E in the Huffman code for this alphabet?
1
2
3
4
Correct answer
3
Correct answer
Consider the following function:
Correct answer
Correct answer
Which of the following statements provides the most accurate definition of the complexity class NP?
It is the class of decision problems that can be solved by a deterministic algorithm in polynomial time.
It is the class of decision problems for which a proposed solution can be verified by a deterministic algorithm in polynomial time.
It is the class of complex problems that can never be solved in polynomial time under any circumstances.
It is the class of optimization problems that can only be solved using a non- polynomial greedy strategy.
Correct answer
It is the class of decision problems for which a proposed solution can be verified by a deterministic algorithm in polynomial time.
Which of the following statements is/are true about quicksort?
Quicksort and merge sort are both examples of divide and conquer algorithms.
The standard in-place implementation of quicksort preserves the relative order of equal elements, making it a stable sorting algorithm.
Correct answers
Quicksort and merge sort are both examples of divide and conquer algorithms.
Let G be a simple, undirected graph with n = 10 vertices. If G is disconnected, which of the following could be the total number of edges (e) in G? (Select all that apply)
45
37
36
35
33
Correct answers
36
35
33
Which of the following edges cannot be present in the original graph? (Select all that apply)
Correct answers
Correct answers
(1, 3)
(5, 1)
(4, 2)
(3, 4)
(3, 2)
Correct answers
(5, 1)
(4, 2)
(3, 2)