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
Here is a function to return the count of odd numbers in the list. There is a logical error in this function.

Select the input list for whichbad_count_oddproduces incorrect output.
Select the input list for whichbad_count_oddproduces incorrect output.
Solution
Match the correct asymptotic complexity for each function.

Solution
Consider the below function for selection sort algorithm.

Assume that the listL=[25, 17, 20, 10, 15]is passed to the functionselectionsort()as parameter. What will be the listLafter thesecond passof selection sort?
Assume that the listL=[25, 17, 20, 10, 15]is passed to the functionselectionsort()as parameter. What will be the listLafter thesecond passof selection sort?
Solution
Which of the following scenarios is an example wherelinear searchis more practical or efficient than thebinary search?
Solution
Consider the following classNode:

Consider an implementation of a linked list where each node is created using the given classNode. Supposeheadpoints to the first node of the linked list. Assume that the linked list is insorted order.

What is an efficient way to count duplicate values in the linked list?
Consider an implementation of a linked list where each node is created using the given classNode. Supposeheadpoints to the first node of the linked list. Assume that the linked list is insorted order.
What is an efficient way to count duplicate values in the linked list?
Solution
If you have an empty stack and you perform the following sequence of operations:

What is the value of the top element on the stack?
What is the value of the top element on the stack?
Solution
A directed graphGhas7vertices. What is the maximum number of edges inG?
Solution
Consider the following DAG.

How many valid topological sorts exist?
How many valid topological sorts exist?
Solution
There are 7 systems (0,..,6) connected in a network as shown in the figure given below.

Which of the following system (node) failures will result in the network being disconnected?
Which of the following system (node) failures will result in the network being disconnected?
Solution
Consider a directed graph given below:
Vertices:{0,1,2,3}
Edge weights:
(0, 1) = 1
(0, 2) = 4
(1, 2) = 2
(1, 3) = 6
(2, 3) = 3
What is the shortest distance from node0to node3?
Vertices:{0,1,2,3}
Edge weights:
(0, 1) = 1
(0, 2) = 4
(1, 2) = 2
(1, 3) = 6
(2, 3) = 3
What is the shortest distance from node0to node3?
Solution
In the Floyd–Warshall algorithm, which of the following aretrue?
Solution
Let G be a complete undirected graph on 4 vertices, having 6 edges with weights being2, 5, 7, 9, 12,
14. The maximum possible total weight that a minimum weight spanning tree of G can have is __.
14. The maximum possible total weight that a minimum weight spanning tree of G can have is __.
Solution
Consider a binary tree with21nodes, where the number of nodes with two children is9. The number of nodes with one child node is _____.
Solution
Consider the following max-heap.

Which of the following cannot be the last element inserted into the heap?
Which of the following cannot be the last element inserted into the heap?
Solution
If we perform the following operations in the given order on the min-heap[12, 25, 18, 40, 35, 30, 28, 50, 45]then the resulting min-heap would be__.

Solution
What is the maximum number of nodes in an AVL tree of height9? Consider that the height of the empty tree is0.
Solution
The weighted path length (WPL) of a Huffman tree over an alphabet A is defined as:
1.
2. Where the depth is the number of edges from the root to the letter
If a Huffman code is constructed for text with frequencies{1, 1, 2, 3, 5, 8}, what is the total weighted path length of the tree?
1.
2. Where the depth is the number of edges from the root to the letter
If a Huffman code is constructed for text with frequencies{1, 1, 2, 3, 5, 8}, what is the total weighted path length of the tree?
Solution
For which of the following coin denominations does theGreedy strategyof choosing the largest coin that does not exceed the target fail to produce the minimum number of coins to make the amount 8?
Solution
In a listL, two elementsL[i]andL[j]form aninversionifL[i]>L[j]andi < j. The total number of inversions forL = [3, 4, 2, 1, 5]is___
Solution
Consider the following recurrence relation for an algorithm -
with base case
. The complexity of this algorithm is____
Solution
Consider the following functionMoM.

What median value will be returned by the givenMoMfunction for the following list?
[1, 3, 7, 4, 3, 2, 7, 9, 15, 12, 19, 25, 16, 17, 11, 17, 21, 28, 18, 30]
What median value will be returned by the givenMoMfunction for the following list?
[1, 3, 7, 4, 3, 2, 7, 9, 15, 12, 19, 25, 16, 17, 11, 17, 21, 28, 18, 30]
Solution
Consider the functionmystery()that takes stringsXandYas input. What willmystery('ABCDFGH','ACDFHBG') return?LCS(X,Y)returns the length of the longest common subsequence of X and Y.

Solution
Consider the following grid.

How many unique paths are available from
to
? Condition is that you can only travel one-step right or one step up at a time, and a gray box at intersection point
and
represents a blockage.
How many unique paths are available from
Solution
A factory produces two types of toys: Toy A and Toy B. The profit is Rs 4 for Toy A and Rs 3 for Toy B.
- Each Toy A takes twice the machine time of Toy B. If the factory only made Toy B, it could produce 1200 units per day.
- The total daily availability of plastic is sufficient to produce 600 toys in total.
- Each Toy A needs a special chip, and only 250 chips are available daily.
- Each Toy B needs a spring, and only 400 springs are available daily.
Let
and
be the number of Toy A and Toy B manufactured each day. Which of the following is not a validconstraint for the Linear Programming formulation?
- Each Toy A takes twice the machine time of Toy B. If the factory only made Toy B, it could produce 1200 units per day.
- The total daily availability of plastic is sufficient to produce 600 toys in total.
- Each Toy A needs a special chip, and only 250 chips are available daily.
- Each Toy B needs a spring, and only 400 springs are available daily.
Let
Solution
Consider a network flow edges
,
,
,
and
. What is the maximum flow allowed from
to
?
Solution
Shape
Thickness [ / ]
3
All colors