Question 1
A, C, F, B, E, D
A, C, F, B, D, E
A, C, B, F, E, D
A, C, B, F, D, E

The IIT Madras BS Programming, Data Structures and Algorithms using Python (PDSA) Quiz 2 paper sat on 4 Aug 2024, in the May 2024 term: 16 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
A, C, F, B, E, D
A, C, F, B, D, E
A, C, B, F, E, D
A, C, B, F, D, E
Correct answer
A, C, F, B, E, D
Correct answer
Consider a directed graph G with equal edge weights. Which of the following algorithms is most efficient to compute the shortest distance between every pair of nodes in G?
Run BFS once on every node
Run Dijkstra’s algorithm once on every node
Run Bellman Ford’s algorithm once on every node
Run Floyd-Warshall algorithm
Correct answer
Run BFS once on every node
Only 1
Only 2
Both 1 and 2
Neither 1 nor 2
Correct answer
Both 1 and 2
[6, 7, 13, 9, 19, 16, 21, 26, 11]
[6, 7, 13, 9, 19, 16, 21, 11, 26]
[6, 7, 13, 9, 19, 21, 16, 26, 11]
[6, 7, 13, 9, 19, 21, 16, 11, 26]
Correct answer
[6, 7, 13, 9, 19, 16, 21, 26, 11]
Which one of the following is a possible sequence of elements in root-to-leaf paths in a top-down fashion in a binary search tree?
50, 10, 36, 40, 31, 46
50, 90, 75, 88, 62, 68
45, 50, 49, 48, 44, 47
45, 50, 46, 49, 47, 48
Correct answer
45, 50, 46, 49, 47, 48
While inserting the elements 45, 75, 15, 55, 5, 40, 62, 25, and 85 in an empty binary search tree in the sequence shown, the elements at maximum depth from root are__________________.
40, 85
25, 40
62, 85
25, 62
Correct answer
25, 62
Correct answer
4
3
2
1
Correct answer
2
Correct answer
Let G be a complete undirected graph with 5 vertices and 10 edges with weights of 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10. The maximum possible weight that a minimum weight spanning tree of G can have is __________________.
Correct answer: 14
Correct answer: 256
Correct answer: 13
Which of the following statements is/are true for Heap sort?
Correct answers
For a set of symbols with probabilities of occurrence, which of the following statement(s) is/are true about the Huffman algorithm?
Symbols with lower probabilities value are generally closer to the root of the Huffman tree.
The Huffman tree is always a strict binary tree (each node has two children, except leaf nodes).
It generates prefix codes (no code is a prefix of another).
If probability values are distinct, then two symbols with the lowest probabilities always have the same code length.
There is always at least one symbol with a code of length one.
Correct answers
The Huffman tree is always a strict binary tree (each node has two children, except leaf nodes).
It generates prefix codes (no code is a prefix of another).
If probability values are distinct, then two symbols with the lowest probabilities always have the same code length.
coins=[1, 2, 8, 9, 5, 10] and x = 13
coins=[10, 1, 2, 5] and x = 25
coins=[6, 1, 5, 7] and x = 15
coins = [1, 6, 7, 10, 15] and x = 35
coins = [1, 2, 5, 10, 25] and x = 40
Correct answers
coins=[1, 2, 8, 9, 5, 10] and x = 13
coins = [1, 6, 7, 10, 15] and x = 35