Question 1 | MCQ
THIS IS QUESTION PAPER FOR THE SUBJECT"DIPLOMA LEVEL : PROGRAMMING, DATA STRUCTURES AND ALGORITHMS USING PYTHON (COMPUTER BASED EXAM)"
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT?
CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN.
(IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
Solution
In the given graph, if we try to find the shortest path from nodePto all other nodes using Dijkstra’s algorithm, which node is the
node to be included in thevisitedset? Consider thatPis the1stvisited node.

Solution
Consider the following algorithm to solve thesingle source shortest pathproblem for a graph (directed or undirected) with positive integer edge weights and a source vertexs.Replace each edge(u,v)of weightwin the graph with a path of lengthwconsisting of unit-weight edges fromuto v(by introducing new intermediate vertices).
For example: edge(u, v)with weightw = 3

RunBFSon this modified graph from the sourcesto find the shortest path to each of the original vertices in the graph.
Which of the following statements is/are true?
I.The algorithm solves the single source shortest path problem correctly.
II.Although the size of the modified graph is larger than the original graph, the algorithm is as efficient as Dijkstra’s algorithm.
For example: edge(u, v)with weightw = 3
RunBFSon this modified graph from the sourcesto find the shortest path to each of the original vertices in the graph.
Which of the following statements is/are true?
I.The algorithm solves the single source shortest path problem correctly.
II.Although the size of the modified graph is larger than the original graph, the algorithm is as efficient as Dijkstra’s algorithm.
Solution
What is the weight of aminimum spanning treein the graph given below?

Solution
Let
be aconnected undirected graphwithdistinct positive edge weights.Consider apartition (cut)of the vertex set
into twonon-emptysubsets
and
such that:
-
, and
-
Let
be theminimum-weight edgeamong all edges thatcross this cut, i.e.,
and
.
Which of the following statements is/are true?
I.For every pair of nodes
such that
and
, the edge
must lie on theshortest pathfrom
to
.
II.The edge
must be part of theminimum spanning tree (MST)of
.
-
-
Let
Which of the following statements is/are true?
I.For every pair of nodes
II.The edge
Solution
Consider amax-heapof size
consisting ofdistinctelements and implemented using an array. Which of the following operations can be performed in
time?
Solution
Consider amax-heapof size
consisting ofdistinctelements and implemented using an array.Which of the following statements is/aretrueabout themax-heap?
Solution
Comprehension Passage
The height of abinary search treeis defined as the number of nodes in the longest path from the root to the leaf (both included). Consider a binary search tree
of height
. Note that
need not be balanced.
Based on the above data, answer the given subquestions.
Based on the above data, answer the given subquestions.
What is the worst-case running time complexity of the searching operation in
?
Solution
Comprehension Passage
The height of abinary search treeis defined as the number of nodes in the longest path from the root to the leaf (both included). Consider a binary search tree
of height
. Note that
need not be balanced.
Based on the above data, answer the given subquestions.
Based on the above data, answer the given subquestions.
Suppose the number of elements in
is
. Which of the following statement(s) is/arecorrect?
Solution
What is the minimum number of nodes possible in anAVL treeof height6? Consider the tree with a single node having height 1.
Solution
After inserting the following elements into an emptyAVL Tree:
30, 20, 10, 28, 25, 40
Which of the following nodes will be the root in the final AVL Tree?
30, 20, 10, 28, 25, 40
Which of the following nodes will be the root in the final AVL Tree?
Solution
Given below is a set of characters and their frequencies:

UsingHuffmanencoding, construct the Huffman tree for this set of characters. What is the maximum number of bits needed to encode any character?
UsingHuffmanencoding, construct the Huffman tree for this set of characters. What is the maximum number of bits needed to encode any character?
Solution
Consider a problem scenario where you have to conduct
job interviews
. Each candidate is available only betweenstart_timeandend_time. If any interview finishes at timeT, then the other interviews can be started at timeTor afterwards.
Which of the following greedy strategies would you apply to schedule the interviews such that the maximum number of candidates can be interviewed without any conflicts?
Which of the following greedy strategies would you apply to schedule the interviews such that the maximum number of candidates can be interviewed without any conflicts?
Solution
In an integer listLof lengthn, two elementsL[i]andL[j]form an inversion ifL[i] > L[j]andi < j.
Consider a listLof lengthnin which all elements are distinct and the listLhas
inversions. The minimumpossible value ofnis ___.
Consider a listLof lengthnin which all elements are distinct and the listLhas
Solution
Which of the following statements isincorrect?
Solution
Consider the following recursive function to return the minimum element in the listLof sizen.
def find_min(L, low, high):
if low == high:
return L[low] mid = (low + high) // 2 min1 = find_min(L, low, mid) min2 = find_min(L, mid+1, high) return min(min1, min2)
Which of the following represents the correct recurrence relation for the given functionfind_min?
def find_min(L, low, high):
if low == high:
return L[low] mid = (low + high) // 2 min1 = find_min(L, low, mid) min2 = find_min(L, mid+1, high) return min(min1, min2)
Which of the following represents the correct recurrence relation for the given functionfind_min?
Solution
Consider the following recurrences and choose the correct option.
1.
2.
Base Case:
1.
2.
Base Case:
Solution
Shape
Thickness [ / ]
3
All colors