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 even numbers in the list. There is a logical error in this function.

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

Solution
Consider the below function for selection sort algorithm.

Assume that the listL=[15, 12, 18, 13, 11]is passed to the functionselectionsort()as parameter. What will be the listLafter thesecond passof selection sort?
Assume that the listL=[15, 12, 18, 13, 11]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 binary search?
Solution
Suppose we are sorting a list of eight integers using quicksort, and we have just finished the first partitioning. The list looks like this:
[12, 18, 25, 7, 30, 55, 60, 40]
Suppose the first element in the list is selected as the pivot for partitioning each time. Which of the following could have been the pivot for the first partitioning?
[12, 18, 25, 7, 30, 55, 60, 40]
Suppose the first element in the list is selected as the pivot for partitioning each time. Which of the following could have been the pivot for the first partitioning?
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 remove all 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 remove all 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
There are 8 systems (0,..,7) connected in network as shown in the figure given below.

Which edge should we add to the network so that the network stays connected when one of the systems is down?
Which edge should we add to the network so that the network stays connected when one of the systems is down?
Solution
Consider the following DAG.

How many valid topological sorts exist?
How many valid topological sorts exist?
Solution
Let
be an undirected graph and
be a BFS traversed tree of
with roots. Which of the following isTruefor everynon-tree edge(u,v)?
Solution
Consider the following graph.

What is the shortest distance from node0to node5?
What is the shortest distance from node0to node5?
Solution
Suppose we run the Bellman-Ford algorithm on a graph withnon-negativeedges. Then compared to Dijkstra's algorithm, the Bellman-Ford algorithm will ___?
Solution
Let
and
be the minimum-cost spanning trees obtained by running Prim's algorithm and Kruskal's algorithm on a graph G. Suppose that
is different from
. Which of the followingmust be true?
Solution
Consider a binary tree with15nodes, where the number of nodes with two children is6. The number of nodes with one child node is _______.
Solution
If we perform the following operations in the given order on the max-heap[89, 62, 31, 45, 51, 29, 30, 42, 34]then the resulting max-heap would be__.

Solution
What is the minimum number of nodes in an AVL tree of height7? Consider that the height of the empty tree is 0.
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{2, 4, 6, 9, 16, 20}, 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{2, 4, 6, 9, 16, 20}, 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 6?
Solution
In a listL, two elementsL[i]andL[j]form asignificant inversionifL[i]>2 * L[j]andi < j. The total number of significant inversions forL = [5, 4, 1, 2, 3]is___.
Solution
Solution
Consider the following functionMoM.

What median value will be returned by the givenMoMfunction for the following list?

What median value will be returned by the givenMoMfunction for the following list?
Solution
Consider the functionmystery()that takes stringsXandYas input. What willmystery('XYITCRT','WTXITRY') return?
LCS(X,Y)returns the length of the longest common subsequence of X and Y.

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
The ABC leather company is manufacturing two types of leather Jackets, Jacket X and Jacket Y. The respective profits are Rs 5 and Rs 6 per Jacket. The production of each of type X requires twice as much time as a Jacket of type Y, and if all Jackets were of type Y, the company could make 1,000 Jackets per day. The supply of leather is sufficient for only 500 Jackets per day (both X and Y combined). Jacket X requires a fancy collar and only 200 collars are available per day. There are only 500 collars a day available for Jacket Y.
The above problem is to be formulated as a linear programming problem. Let
and
be the number of jackets of type X and Y, respectively, manufactured each day. Which of the following is not a validconstraint?
The above problem is to be formulated as a linear programming problem. Let
Solution
Consider a network flow edges
,
,
,
and
. What is the maximum flow allowed from
to
?
Solution
Shape
Thickness [ / ]
3
All colors