PDSA End Term: 3 April 2022, Set AN1 (January 2022 term)
The IIT Madras BS Programming, Data Structures and Algorithms using Python (PDSA) End Term paper sat on 3 Apr 2022, in the January 2022 term, set AN1: 30 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.
- 30
- 100
- 180 min
- 22
- 4
- 4
Show answer
Correct answer
Question 2
Which of the following statements is/are true about the Quicksort algorithm? Assume that the first element in the list selected as pivot for partitioning each time.
I. The best case is when the pivot element always divides the list into two equal halves. II. The worst case is when the input list is arranged in either ascending or descending order.
Only I
Only II
Both I and II
None
Show answer
Correct answer
Both I and II
Question 3
Insertion of the new node at the front of the linked list.
Insertion of the new node at the end of the linked list.
Deletion of the first node of the linked list.
Deletion of the last node of the linked list.
Show answer
Correct answer
Deletion of the last node of the linked list.
Question 4
2, 3, 1, 4, 3, 4, 3, 3
4, 2, 2, 3, 1, 3, 3, 5
1, 2, 3, 1, 4, 2, 1, 2
1, 2, 2, 2, 2, 1, 3, 4
Show answer
Correct answer
1, 2, 3, 1, 4, 2, 1, 2
Question 5
Show answer
Correct answer
Question 6
Show answer
Correct answer
Question 7
Show answer
Correct answer
Question 8
A data structure is required for storing a set of integers such that each of the following operations can be done in O(log n) time, where n is the number of elements in the set.
I. Deletion of the smallest element
II. Insertion of an element if it is not already present in the set
Which of the following options are true?
A heap can be used but not a balanced binary search tree
A balanced binary search tree can be used but not a heap
Both balanced binary search tree and heap can be used
Neither balanced search tree nor heap can be used
Show answer
Correct answer
A balanced binary search tree can be used but not a heap
Question 9
Suppose the letters {a, b, c, d, e} occur with the following frequencies.
How many bits will be used to encode the letter d in the Huffman code for this alphabet?
1
2
3
4
Show answer
Correct answer
2
Question 10
2
3
4
5
Show answer
Correct answer
3
Question 11
Show answer
Correct answer
Question 12
Show answer
Correct answer
Question 13
7
8
9
10
Show answer
Correct answer
10
Question 14
Which of the following option represents the fail function (or prefix function) for pattern 'bonbon' in the Knuth-Morris-Pratt (KMP) algorithm?
[0, 0, 0, 1, 1, 2]
[0, 0, 0, 1, 2, 3]
[0, 0, 1, 2, 3, 3]
[0, 0, 0, 0, 1, 2]
Show answer
Correct answer
[0, 0, 0, 1, 2, 3]
Question 15
A problem in NP is NP-complete if___________
It can be reduced to the 3-SAT problem in polynomial time
It can be reduced to any other problem in NP in polynomial time
some problem in NP can be reduced to it in polynomial time
The 3-SAT problem can be reduced to it in polynomial time
Show answer
Correct answer
The 3-SAT problem can be reduced to it in polynomial time
Question 16
A company makes two kinds of leather belts, belt A and belt B. Belt A is a high quality belt and belt B is of lower quality. The respective profits are Rs 5 and Rs 6 per belt. The production of each of type A requires twice as much time as a belt of type B, and if all belts were of type B, the company could make 1,000 belts per day. The supply of leather is sufficient for only 800 belts per day (both A and B combined). Belt A requires a fancy buckle and only 300 of these are available per day. There are only 800 buckles a day available for belt B.
The above problem is to be formulated as a linear programming problem. Let x1 and x2 be the number of belts of type A and B, respectively, manufactured each day. Which of the following is not a valid constraint?
x1 ≤ 300
x2 ≤ 800
x1 + 2x2 ≤ 1000
2x1 + x2 ≤ 1000
Show answer
Correct answer
x1 + 2x2 ≤ 1000
Question 17
Leaves the stack S unchanged
Reverses the order of elements in the stack S
Swaps the elements of the top and bottom positions in stack S, keeping the other elements in between in the same order
Empties the stack S
Show answer
Correct answer
Leaves the stack S unchanged
Question 18
Show answer
Correct answer
Question 19
0
1
2
3
Show answer
Correct answer
2
Question 20
Show answer
Correct answer
Question 21
23, 36, 72, 12, 54, 83
36, 72, 23, 12, 54, 83
36, 23, 72, 12, 83, 54
36, 23, 72, 12, 54, 83
72, 23, 36, 54, 12, 83
Show answer
Correct answers
23, 36, 72, 12, 54, 83
36, 72, 23, 12, 54, 83
36, 23, 72, 12, 54, 83
Question 22
Suppose we obtain the following BFS tree rooted at node G for an undirected graph with vertices {A, B, C, D, E, F, G, H, I, J, K}.
Which of the following can not be an edge/edges in the original graph?
Show answer
Correct answers
Question 23
Which of the following statement is true about Dijkstra's algorithm to find shortest path?
Dijkstra’s algorithm doesn’t work for graphs with negative weights.
It returns the shortest path between all pair of nodes.
The shortest path returned by Dijkstra's algorithm always passes through the least number of vertices.
To decide which node to visit next, Dijkstra's algorithm selects the node with smallest known distance
It can find the shortest path for only acyclic graphs
Show answer
Correct answers
Dijkstra’s algorithm doesn’t work for graphs with negative weights.
To decide which node to visit next, Dijkstra's algorithm selects the node with smallest known distance
Question 24
Which of the following statements is true about binary trees? Assume that the height of the empty tree is 0.
If the number of nodes in the tree is n, then the maximum height of the tree can be n.
If the number of nodes in the tree is n, then the minimum height of the tree will be int(log(n)) + 1.
The number of leaf nodes is always one more than the number of non-leaf nodes.
If number of nodes in the tree is n, then the number of edges in the tree will be n + 1.
Maximum number of nodes at level L will be 2*^(L)* (if level number starts from 0(root node)).
Show answer
Correct answers
If the number of nodes in the tree is n, then the maximum height of the tree can be n.
If the number of nodes in the tree is n, then the minimum height of the tree will be int(log(n)) + 1.
Maximum number of nodes at level L will be 2*^(L)* (if level number starts from 0(root node)).
Question 25
What is the weight of the minimum spanning tree for the given graph?
NOTE: Enter your answer to the nearest integer.
Show answer
Correct answer: 13
Question 26
NOTE: Enter your answer to the nearest integer.
Show answer
Correct answer: 54
Question 27
NOTE: Enter your answer to the nearest integer.
Show answer
Correct answer: 4
Question 28
NOTE: Enter your answer to the nearest integer.
Show answer
Correct answer: 17
Question 29
Based on the above data, answer the given subquestions.
length of the longest strictly decreasing subsequence
length of the longest strictly increasing subsequence
length of the longest contiguous strictly decreasing sequence
length of the longest contiguous strictly increasing sequence
Show answer
Correct answer
length of the longest strictly decreasing subsequence
Question 30
Based on the above data, answer the given subquestions.
Show answer
Correct answer
