MauryaHub PYQ Practice

Programming, Data Structures and Algorithms using Python · End Term · Sep 2025 · AN

Programming, Data Structures and Algorithms using Python · End Term · Sep 2025 AN

← Course papers · Start practice / exam

Questions and published explanations below are available without starting a test. Some questions may not have a published solution yet.

0 / 25 published solutions

Question 2 MCQ · 4.0 marks

Here is a function to return the count of odd numbers in the list. There is a logical error in this function.
Source diagram or notation
Select the input list for which bad_count_odd produces incorrect output.
A.
[5,31,71,41]
B.
[15,7,3,6,8,34]
C.
[11,3,15,31]
D.
[5,4,13,30]

A published solution is not available for this question yet.

Report a correction for Q2

Question 3 MCQ · 4.0 marks

Match the correct asymptotic complexity for each function.
Source diagram or notation
A.
1-b, 2-c, 3-a, 4-d, 5-e
B.
1-a, 2-d, 3-b, 4-c, 5-e
C.
1-e, 2-c, 3-b, 4-a, 5-d
D.
1-a, 2-c, 3-b, 4-d, 5-e

A published solution is not available for this question yet.

Report a correction for Q3

Question 4 MCQ · 4.0 marks

Consider the below function for selection sort algorithm.
Source diagram or notation
Assume that the list L=[25, 17, 20, 10, 15] is passed to the function selectionsort() as parameter. What will be the list L after the second pass of selection sort?
A.
[10, 15, 20, 25, 17]
B.
[10, 25, 20, 17, 15]
C.
[10, 15, 25, 20, 17]
D.
[25, 17, 20, 10, 15]

A published solution is not available for this question yet.

Report a correction for Q4

Question 5 MSQ · 4.0 marks

Which of the following scenarios is an example where linear search is more practical or efficient than the binary search?
A.
The list has only 3–4 elements.
B.
The list is unsorted and searching must be done immediately.
C.
The element being searched is at the middle index of a large sorted list.
D.
The list changes frequently, making it expensive to maintain sorted order.
E.
The list is sorted and stored in an array with random access available.

A published solution is not available for this question yet.

Report a correction for Q5

Question 6 MCQ · 4.0 marks

Consider the following class Node:
Source diagram or notation
Consider an implementation of a linked list where each node is created using the given class Node. Suppose head points to the first node of the linked list. Assume that the linked list is in **sorted** **order**.
Source diagram or notation
What is an efficient way to count duplicate values in the linked list?
A.
Traverse the linked list once, comparing each node with its immediate successor and count duplicates.
B.
Traverse the linked list once and store each node’s value in a hash table to count duplicates.
C.
Use a nested loop to compare each node with all other nodes and count duplicates.
D.
Recursively traverse the linked list from the tail and count duplicates.

A published solution is not available for this question yet.

Report a correction for Q6

Question 7 NAT · 4.0 marks

If you have an empty stack and you perform the following sequence of operations:
Source diagram or notation
What is the value of the top element on the stack?

A published solution is not available for this question yet.

Report a correction for Q7

Question 8 NAT · 4.0 marks

A directed graph G has 7 vertices. What is the maximum number of edges in G?

A published solution is not available for this question yet.

Report a correction for Q8

Question 9 NAT · 4.0 marks

Consider the following DAG.
Source diagram or notation
How many valid topological sorts exist?

A published solution is not available for this question yet.

Report a correction for Q9

Question 10 MCQ · 4.0 marks

There are 7 systems (0,..,6) connected in a network as shown in the figure given below.
Source diagram or notation
Which of the following system (node) failures will result in the network being disconnected?
A.
0
B.
2
C.
4
D.
3

A published solution is not available for this question yet.

Report a correction for Q10

Question 11 MCQ · 4.0 marks

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 node 0 to node 3 ?
A.
9
B.
8
C.
7
D.
6

A published solution is not available for this question yet.

Report a correction for Q11

Question 12 MSQ · 4.0 marks

In the Floyd–Warshall algorithm, which of the following are **true**?
A.
It uses dynamic programming.
B.
It can detect negative cycles.
C.
It maintains a predecessor matrix for path reconstruction (when implemented with one).
D.
It cannot be applied to undirected graphs.

A published solution is not available for this question yet.

Report a correction for Q12

Question 13 NAT · 4.0 marks

Let G be a complete undirected graph on 4 vertices, having 6 edges with weights being 2, 5, 7, 9, 12, 14. The maximum possible total weight that a minimum weight spanning tree of G can have is __.

A published solution is not available for this question yet.

Report a correction for Q13

Question 14 MCQ · 4.0 marks

Consider a binary tree with 21 nodes, where the number of nodes with two children is 9. The number of nodes with one child node is _____.
A.
4
B.
3
C.
2
D.
1

A published solution is not available for this question yet.

Report a correction for Q14

Question 15 MSQ · 4.0 marks

Consider the following max-heap.
Source diagram or notation
Which of the following cannot be the last element inserted into the heap?
A.
77
B.
10
C.
31
D.
17
E.
36

A published solution is not available for this question yet.

Report a correction for Q15

Question 16 MCQ · 4.0 marks

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__.
Source diagram or notation
A.
[18, 20, 28, 40, 25, 30, 50, 45, 35]
B.
[18, 25, 20, 40, 35, 30, 28, 50, 45]
C.
[18, 20, 28, 25, 35, 30, 40, 50, 45]
D.
[18, 25, 20, 35, 40, 28, 30, 50, 45]

A published solution is not available for this question yet.

Report a correction for Q16

Question 17 NAT · 4.0 marks

What is the maximum number of nodes in an AVL tree of height 9? Consider that the height of the empty tree is 0.

A published solution is not available for this question yet.

Report a correction for Q17

Question 18 NAT · 4.0 marks

The weighted path length (WPL) of a Huffman tree over an alphabet A is defined as: 1.
Source diagram or notation
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?

A published solution is not available for this question yet.

Report a correction for Q18

Question 19 MCQ · 4.0 marks

For which of the following coin denominations does the Greedy strategy of choosing the largest coin that does not exceed the target fail to produce the minimum number of coins to make the amount 8?
A.
{1, 4, 6}
B.
{1, 3, 4}
C.
{1, 5, 7}
D.
{1, 2, 6}

A published solution is not available for this question yet.

Report a correction for Q19

Question 20 MCQ · 4.0 marks

In a list L, two elements L[i] and L[j] form an **inversion** if L[i] > L[j] and i < j . The total number of inversions for L = [3, 4, 2, 1, 5] is___
A.
5
B.
4
C.
3
D.
2

A published solution is not available for this question yet.

Report a correction for Q20

Question 21 MCQ · 4.0 marks

Consider the following recurrence relation for an algorithm -
Source diagram or notation
with base case
Source diagram or notation
. The complexity of this algorithm is____
A.Source diagram or notation
B.Source diagram or notation
C.Source diagram or notation
D.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q21

Question 22 NAT · 4.0 marks

Consider the following function MoM.
Source diagram or notation
What median value will be returned by the given MoM function for the following list? [1, 3, 7, 4, 3, 2, 7, 9, 15, 12, 19, 25, 16, 17, 11, 17, 21, 28, 18, 30]

A published solution is not available for this question yet.

Report a correction for Q22

Question 23 MCQ · 4.0 marks

Consider the function mystery() that takes strings X and Y as input. What will mystery('ABCDFGH','ACDFHBG') return? LCS(X,Y) returns the length of the longest common subsequence of X and Y.
Source diagram or notation
A.
10
B.
9
C.
8
D.
7

A published solution is not available for this question yet.

Report a correction for Q23

Question 24 NAT · 4.0 marks

Consider the following grid.
Source diagram or notation
How many unique paths are available from
Source diagram or notation
to
Source diagram or notation
? Condition is that you can only travel one-step right or one step up at a time, and a gray box at intersection point
Source diagram or notation
and
Source diagram or notation
represents a blockage.

A published solution is not available for this question yet.

Report a correction for Q24

Question 25 MCQ · 4.0 marks

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
Source diagram or notation
and
Source diagram or notation
be the number of Toy A and Toy B manufactured each day. Which of the following is **not a valid** constraint for the Linear Programming formulation?
A.Source diagram or notation
B.Source diagram or notation
C.Source diagram or notation
D.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q25

Question 26 MCQ · 4.0 marks

Consider a network flow edges
Source diagram or notation
,
Source diagram or notation
,
Source diagram or notation
,
Source diagram or notation
and
Source diagram or notation
. What is the maximum flow allowed from
Source diagram or notation
to
Source diagram or notation
?
A.
16
B.
15
C.
14
D.
13

A published solution is not available for this question yet.

Report a correction for Q26