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)
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)
Solution
Inscript
Consider the following function:

If the function is called as:

What value will the function return?
Consider the following function:
If the function is called as:
What value will the function return?
Solution
Inscript
In abinary tree, the total number of nodes is28. It is known that10 nodes have exactly two children.
How many nodes haveexactly one child?
In abinary tree, the total number of nodes is28. It is known that10 nodes have exactly two children.
How many nodes haveexactly one child?
Solution
Inscript
While inserting the elements 60, 30, 50, 55, 80, 90, 65, 70, and 10 into an empty binary search tree (BST) in the sequence shown, the sum of elements at maximum depth is __.
While inserting the elements 60, 30, 50, 55, 80, 90, 65, 70, and 10 into an empty binary search tree (BST) in the sequence shown, the sum of elements at maximum depth is __.
Solution
Inscript
An entire message is created using characters from the set

The probability of occurrence of each character is given in the table below.

How manybitswill be used to encode the messageABCDEusingHuffman codes?
An entire message is created using characters from the set
The probability of occurrence of each character is given in the table below.
How manybitswill be used to encode the messageABCDEusingHuffman codes?
Solution
Inscript
In a list
, two elements
and
form asignificant inversionif
and
.
The total number of significant inversions for
is ___ .
In a list
The total number of significant inversions for
Solution
Arrange the above functions inincreasing order of asymptotic complexity.
Solution
A list of
strings, each of length
is sorted inlexicographical orderusing the Merge Sort algorithm. What is its time complexity? (Assume that comparing strings lexicographically takes
)
Solution
Consider thatQuick sortis applied on a list of size
which issorted in reverse order. What will be the asymptotic running time of Quick sort if the pivot is taken to be
First element
Last element
Choose the correct option corresponding to the correct pair of complexities for both pivots.
Choose the correct option corresponding to the correct pair of complexities for both pivots.
Solution
Consider the following class
:

Consider an implementation of a linked list where each node is created using the given class
. Suppose it has a
variable that points to the first node of the linked list.

Suppose we want to perform the following operations on the linked list containing
nodes:
1.Insertion of a new node at thefirst positionof the linked list
2.Insertion of a new node at thelast positionof the linked list
3.Deletion of thefirst nodeof the linked list
4.Deletion of thelast nodeof the linked list
Using themost efficient algorithm, which of the following options correctly represents thetime complexity of the above operations respectively?
Consider an implementation of a linked list where each node is created using the given class
Suppose we want to perform the following operations on the linked list containing
1.Insertion of a new node at thefirst positionof the linked list
2.Insertion of a new node at thelast positionof the linked list
3.Deletion of thefirst nodeof the linked list
4.Deletion of thelast nodeof the linked list
Using themost efficient algorithm, which of the following options correctly represents thetime complexity of the above operations respectively?
Solution
Consider the followingundirected graph
.

RunBFS starting from vertex A. If multiple adjacent vertices exist, they are visited in alphabetical order.
Which of the following is thecorrect BFS traversal order?
RunBFS starting from vertex A. If multiple adjacent vertices exist, they are visited in alphabetical order.
Which of the following is thecorrect BFS traversal order?
Solution
Consider aconnected, directed graph
on whichDFSis executed.
and
numbering is used in the DFS algorithm on the graph.
In which of the following situations can we conclude that the edge
is across edge?
In which of the following situations can we conclude that the edge
Solution
The Bellman-Ford algorithm cannot be used if a graph has negative cycles. This is because:
Solution
While inserting the elements 8, 4, 1, 3, 9, 2, and 11 in an empty AVL tree in the given sequence, the leaf elements are__.
Solution
Consider the following activities
.

We can execute one activity at a time. Each activity
has activity duration
, which represents the time required to complete, and a deadline
. Consider the initial start time
to start the first selected activity.
Let the lateness of a schedule be the maximum amount by which any single activity is late in that schedule. What is theminimumlateness across all possible schedules?
We can execute one activity at a time. Each activity
Let the lateness of a schedule be the maximum amount by which any single activity is late in that schedule. What is theminimumlateness across all possible schedules?
Solution
Consider the following recurrence relation for an algorithm:

with base case
.
The complexity of this algorithm is ___
with base case
The complexity of this algorithm is ___
Solution
Consider four matrices
and
of dimensions
and
respectively. If
and
, then which of the following takes the least time for computation?
Solution
Assume there are
teachers and 2n subjects. Each teacher has to teach exactly 2 subjects. Their preferences are modelled as a directed graph
, such that there exists an edge from a teacher node
to a subject node
in
, if
prefers teaching
. How can this problem be modelled as a network flow problem?
Solution
A factory produces two types of gadgetsAandB. The profit earned isRs. 6 per unit of AandRs. 4 per unit of B.
Each gadget must be processed ontwo machines M and N.
- One unit ofArequires2 minutes on machine Mand1 minute on machine N.
- One unit ofBrequires1 minute on machine Mand2 minutes on machine N.
MachineMis available for6 hours (360 minutes)per day and machineNis available for7 hours (420 minutes)per day.
Which of the following is thecorrect Linear Programming formulationto maximize profit?
Let
be the number of units of type A and
be the number of units of type B.
Each gadget must be processed ontwo machines M and N.
- One unit ofArequires2 minutes on machine Mand1 minute on machine N.
- One unit ofBrequires1 minute on machine Mand2 minutes on machine N.
MachineMis available for6 hours (360 minutes)per day and machineNis available for7 hours (420 minutes)per day.
Which of the following is thecorrect Linear Programming formulationto maximize profit?
Let
Solution
Let G be a simple graph with 25 vertices and 50 edges. The size of the minimum vertex cover of G is 10. What is the size of the maximum independent set of G ?
Solution
A hash table of size10usesopen addressing with linear probingand the hash function

After inserting6 keysinto an empty hash table, the final table is:

Which of the followingcould be possible insertion ordersthat produce this table?
After inserting6 keysinto an empty hash table, the final table is:
Which of the followingcould be possible insertion ordersthat produce this table?
Solution
Inscript
Atechnology training instituteoffers an advanced certification program consisting of10 modules. The program is divided intoterms of 4 months.
Students may enroll inany number of modules in a term, but a module can only be takenafter completing all of its prerequisite modules.
The prerequisite structure is given below.

There isno restriction on the number of modules a student can take in a term.
Theminimum number of termsrequired to complete all10 modulesis ___.
Atechnology training instituteoffers an advanced certification program consisting of10 modules. The program is divided intoterms of 4 months.
Students may enroll inany number of modules in a term, but a module can only be takenafter completing all of its prerequisite modules.
The prerequisite structure is given below.
There isno restriction on the number of modules a student can take in a term.
Theminimum number of termsrequired to complete all10 modulesis ___.
Solution
Inscript
There are
stones, numbered
. For each
, the height of Stone
is
.
There is a frog who is initially on Stone
. He will repeat the following action some number of times to reach Stone 
If the frog is currently on stone
, it can jump to Stone
or Stone
. Here, a cost of
is incurred, where
is the stone to land on.
Find the minimum possible total cost to reach stone 5 from stone 0 for the following sequence of heights for 6 stones.

There are
There is a frog who is initially on Stone
If the frog is currently on stone
Find the minimum possible total cost to reach stone 5 from stone 0 for the following sequence of heights for 6 stones.
Solution
Consider the following graph.

Which of the following options correctly represents theshortest distances from node 0 to nodes (1, 2, 3, 4, 5)respectively?
Which of the following options correctly represents theshortest distances from node 0 to nodes (1, 2, 3, 4, 5)respectively?
Solution
Consider the graphGgiven below.

LetMinimum Spanning Trees (MSTs)of the graph be constructed using algorithms such as
Kruskal’s or Prim’s algorithm.
Which of the following statement(s) is/arecorrect?
LetMinimum Spanning Trees (MSTs)of the graph be constructed using algorithms such as
Kruskal’s or Prim’s algorithm.
Which of the following statement(s) is/arecorrect?
Solution
Shape
Thickness [ / ]
3
All colors