Question 1
1
3
4
5
The IIT Madras BS Programming, Data Structures and Algorithms using Python (PDSA) Quiz 2 paper sat on 10 Jul 2022, in the May 2022 term: 15 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.
1
3
4
5
Correct answer
4
Correct answer
Correct answer
Which one of the following can not be a possible sequence of elements in the path from the root to any leaf in a binary search tree?
70, 60, 20, 50, 30, 46
50, 10, 36, 40, 31, 46
20, 75, 58, 30, 55, 46
60, 10, 40, 50, 42, 46
Correct answer
50, 10, 36, 40, 31, 46
A-2, B-4, C-3, D-1
A-2, B-3, C-4, D-1
A-2, B-3, C-1, D-4
A-3, B-2, C-4, D-1
Correct answer
A-2, B-3, C-4, D-1
A-3, B-3, C-5, D-1, E-5, F-4
A-3, B-2, C-5, D-2, E-5, F-4
A-3, B-3, C-5, D-2, E-5, F-4
A-3, B-2, C-5, D-1, E-5, F-4
Correct answer
A-3, B-2, C-5, D-1, E-5, F-4
Which of the following statement(s) is/are true?
Given a graph where all edges have positive weights, the shortest path produced by Dijkstra's and Bellman-Ford algorithm may be different, but the path weight would be the same.
Given a graph where weights of all edges are unique, there is always a unique shortest path from a source to destination in such a graph.
Bellman-Ford and Floyd-Warshall's algorithm can calculate the shortest path correctly if the graph has negative edge weights but does not have negative weight cycles.
The time complexity of Floyd-Warshall isO(V²), where V is the number of vertices in the graph.
Correct answers
Given a graph where all edges have positive weights, the shortest path produced by Dijkstra's and Bellman-Ford algorithm may be different, but the path weight would be the same.
Bellman-Ford and Floyd-Warshall's algorithm can calculate the shortest path correctly if the graph has negative edge weights but does not have negative weight cycles.
Let G = (V,E) be an undirected connected graph with more than two vertices where each edge has a distinct weight, and e is a particular edge of G. Which of the following statement(s) is/are always true about the minimum cost spanning trees (MCSTs) of G ?
If e is the lightest weight edge of some cycle in G, then MCST of G includes e
If e is the heaviest weight edge of some cycle in G, then MCST of G excludes e
If e is the heaviest weight edge in G, then MCST of G excludes e
If e is the lightest weight edge in G, then MCST of G includes e
Correct answers
If e is the heaviest weight edge of some cycle in G, then MCST of G excludes e
If e is the lightest weight edge in G, then MCST of G includes e
Which of the following statement(s) is/are true?
The smallest element in a max-heap is always at a leaf node
The smallest element in a max-heap is always at the lowest level
The second-largest element in a max-heap is always a child of the root node
Finding a minimum element in max-heap takes O(logn) time
Insert a new element in max-heap takes O(logn) time in worst case
Correct answers
The smallest element in a max-heap is always at a leaf node
The second-largest element in a max-heap is always a child of the root node
Insert a new element in max-heap takes O(logn) time in worst case
Correct answers
While inserting the elements 60, 20, 68, 10, 45, 50, 30, 47, and 85 in an empty binary search tree (BST) in the sequence shown, the height of the created binary search tree is__________. Assume that the height of the empty tree is 0.
Correct answer: 5
Correct answer: 6
Correct answer: 6
Based on the above data, answer the given subquestions.
Correct answer
Based on the above data, answer the given subquestions.
Correct answer