MauryaHub PYQ Practice

Programming, Data Structures and Algorithms using Python · End Term · May 2026 · AN

Programming, Data Structures and Algorithms using Python · End Term · May 2026 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 NAT · 4.0 marks

What does the function
Source diagram or notation
return?
Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q2

Question 3 NAT · 4.0 marks

Consider the following implementation for Stack
Source diagram or notation
Which of the following is the return value of the function call
Source diagram or notation
?

A published solution is not available for this question yet.

Report a correction for Q3

Question 4 NAT · 4.0 marks

Consider a graph with 4 vertices
Source diagram or notation
, where all edges running along the perimeter have identical weights, and the single diagonal edge has a different value:
Source diagram or notation
How many distinct, unique minimum spanning trees can be generated for this graph?

A published solution is not available for this question yet.

Report a correction for Q4

Question 5 NAT · 4.0 marks

A custom currency system uses the coin denominations
Source diagram or notation
. A student applies the standard greedy strategy (always choosing the largest possible coin denomination that does not exceed the remaining target amount) to make change for a target value of
Source diagram or notation
. What is the smallest integer target value
Source diagram or notation
for which this greedy strategy fails to find the optimal solution (i.e., it returns a strictly greater number of coins than the absolute minimum required)?

A published solution is not available for this question yet.

Report a correction for Q5

Question 6 NAT · 4.0 marks

Consider the following function
Source diagram or notation
Source diagram or notation
What median value will be returned by the given
Source diagram or notation
function for the following list?
Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q6

Question 7 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 blue boxes at intersection points
Source diagram or notation
and
Source diagram or notation
represent blockages.

A published solution is not available for this question yet.

Report a correction for Q7

Question 8 NAT · 4.0 marks

Let
Source diagram or notation
be a simple graph with 17 vertices. The size of the minimum vertex cover of
Source diagram or notation
is 7. What is the size of the maximum independent set of graph
Source diagram or notation
?

A published solution is not available for this question yet.

Report a correction for Q8

Question 9 MCQ · 4.0 marks

Suppose f(n) is
Source diagram or notation
. Consider the following statements. (i) f(n) is
Source diagram or notation
(ii) f(n) is
Source diagram or notation
(iii) f(n) is
Source diagram or notation
Which of the following is **true**?
A.
(i), (ii) and (iii) are all not true.
B.
(ii) and (iii) are true but (i) is not true.
C.
(iii) is true but (i) and (ii) are not true.
D.
(i) and (ii) are true but (iii) is not true.

A published solution is not available for this question yet.

Report a correction for Q9

Question 10 MCQ · 4.0 marks

We have a list of three dimensional points:
Source diagram or notation
We sort these in ascending order by the third coordinate. Which of the following corresponds to a stable sort of this input?
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 Q10

Question 11 MCQ · 4.0 marks

Consider an empty hash table of size
Source diagram or notation
using open addressing with quadratic probing:
Source diagram or notation
, where
Source diagram or notation
represents the probe number. The keys
Source diagram or notation
are inserted into the table sequentially. What will the hash table look like after these insertions?
A.
Index 1: 12, Index 2: 23, Index 3: 34
B.
Index 1: 12, Index 2: 23, Index 5: 34
C.
Index 1: 12, Index 3: 23, Index 6: 34
D.
Index 1: 12, Index 5: 23, Index 2: 34

A published solution is not available for this question yet.

Report a correction for Q11

Question 12 MCQ · 4.0 marks

Consider a simple, undirected graph
Source diagram or notation
with
Source diagram or notation
vertices. Which of the following degree sequences could not possibly belong to
Source diagram or notation
, even if the graph is disconnected?
A.
6, 4, 3, 2, 2, 1, 0
B.
5, 3, 3, 2, 2, 1, 0
C.
4, 4, 3, 2, 2, 1, 0
D.
5, 3, 2, 2, 1, 1, 0

A published solution is not available for this question yet.

Report a correction for Q12

Question 13 MCQ · 4.0 marks

Suppose a directed graph
Source diagram or notation
contains a negative-weight cycle. We run the Bellman-Ford algorithm starting from a source vertex
Source diagram or notation
. Under which condition will the algorithm fail to detect this negative-weight cycle during its final (
Source diagram or notation
-th) iteration check?
A.
If the negative-weight cycle consists of more than three vertices.
B.
If the total absolute sum of the negative weights in the cycle is smaller than the weight of the source vertex
Source diagram or notation
.
C.
The algorithm will never fail; it is mathematically guaranteed to detect every negative cycle in the graph regardless of its location.
D.
If the negative-weight cycle is located in a component that is completely unreachable from the source vertex
Source diagram or notation
.

A published solution is not available for this question yet.

Report a correction for Q13

Question 14 MCQ · 4.0 marks

In a binary tree
Source diagram or notation
, if the number of leaf nodes is exactly 15, what is the total number of nodes in the tree that have exactly two children?
A.
14
B.
15
C.
16
D.
30

A published solution is not available for this question yet.

Report a correction for Q14

Question 15 MCQ · 4.0 marks

Which of the following lists does not represent a valid
Source diagram or notation
?
A.
[100, 80, 90, 30, 40, 50, 60]
B.
[50, 40, 45, 30, 35, 20, 25]
C.
[90, 85, 70, 88, 60, 55, 45]
D.
[75, 60, 45, 20, 55, 30, 42]

A published solution is not available for this question yet.

Report a correction for Q15

Question 16 MCQ · 4.0 marks

Consider a Binary Search Tree containing the keys
Source diagram or notation
. The root node is
Source diagram or notation
, and its left and right children are
Source diagram or notation
and
Source diagram or notation
, respectively. If you execute a standard deletion operation to remove the root node
Source diagram or notation
, which of the following keys can cleanly replace the root position to keep the structural properties of the BST intact without requiring major reorganization?
A.
3 or 18
B.
5 or 15
C.
7 or 12
D.
3 or 7

A published solution is not available for this question yet.

Report a correction for Q16

Question 17 MCQ · 4.0 marks

Consider an initially empty AVL tree. We insert the following keys in the exact sequence given:
Source diagram or notation
. Which specific node insertion acts as the trigger that forces the tree to execute a Double Rotation?
A.
Insertion of 30
B.
Insertion of 40
C.
Insertion of 50
D.
Insertion of 25

A published solution is not available for this question yet.

Report a correction for Q17

Question 18 MCQ · 4.0 marks

Suppose the letters {A, B, C, D, E} occur with the following frequencies.
Source diagram or notation
How many bits will be used to encode the letter **A** in the Huffman code for this alphabet?
A.
1
B.
2
C.
3
D.
4

A published solution is not available for this question yet.

Report a correction for Q18

Question 19 MCQ · 4.0 marks

Consider a base-case subproblem encountered during the execution of the Closest Pair algorithm that contains exactly 3 points:
Source diagram or notation
,
Source diagram or notation
, and
Source diagram or notation
. What is the local minimum distance (
Source diagram or notation
) evaluated by this brute-force base case, and how many unique pairwise distance calculations must be performed to find it?
A.Source diagram or notation
, performed using 2 distance calculations
B.Source diagram or notation
, performed using 3 distance calculations
C.Source diagram or notation
, performed using 1 distance calculation
D.Source diagram or notation
, performed using 3 distance calculations

A published solution is not available for this question yet.

Report a correction for Q19

Question 20 MCQ · 4.0 marks

Consider the following function:
Source diagram or notation
What is the **purpose** of the above function?
A.
It finds the length of the longest contiguous increasing subarray in
Source diagram or notation
.
B.
It finds the length of the longest increasing subsequence in
Source diagram or notation
.
C.
It finds the maximum element in
Source diagram or notation
using dynamic programming.
D.
It finds the length of the longest decreasing subsequence in
Source diagram or notation
.

A published solution is not available for this question yet.

Report a correction for Q20

Question 21 MCQ · 4.0 marks

A boutique bakery produces specialty gift baskets containing boxes of Artisan Cookies (
Source diagram or notation
) and Gourmet Chocolates (
Source diagram or notation
). For production, the kitchen has 800 kg of premium flour and 1200 kg of refined sugar available in their inventory. • Each box of Cookies (
Source diagram or notation
) requires 2 kg of flour and 1 kg of sugar. • Each box of Chocolates (
Source diagram or notation
) requires 1 kg of flour and 3 kg of sugar. The profit is fixed at Rs. 150 per box of cookies and Rs. 200 per box of chocolates. The objective function is to maximize total profit
Source diagram or notation
. Which of the following is not a valid constraint for this linear programming problem?
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 MSQ · 4.0 marks

Which of the following statements is/are **true** about quicksort?
A.
The partitioning step requires a single linear scan of the subarray, taking
Source diagram or notation
time
B.
If the input array is already sorted in strictly increasing order and we choose the first element as the pivot, this partitioning scheme will split the array into two heavily unbalanced subarrays of sizes roughly
Source diagram or notation
and
Source diagram or notation
C.
In the worst-case scenario, the partitioning step itself degrades and requires
Source diagram or notation
time to complete.
D.
Quicksort always runs in
Source diagram or notation
time, regardless of the order of the input elements and the pivot-selection strategy.
E.
Quicksort and binary search are both examples of divide and conquer algorithms.

A published solution is not available for this question yet.

Report a correction for Q22

Question 23 MSQ · 4.0 marks

Let
Source diagram or notation
be a simple, undirected graph with
Source diagram or notation
vertices. If
Source diagram or notation
is disconnected, which of the following could be the total number of edges (
Source diagram or notation
) in
Source diagram or notation
? (Select all that apply)
A.
45
B.
50
C.
55
D.
60
E.
65

A published solution is not available for this question yet.

Report a correction for Q23

Question 24 MSQ · 4.0 marks

Which of the following statements is/are **false** regarding the topological sorting of a graph? (Select all that apply)
A.
Every Directed Acyclic Graph (DAG) must contain at least one vertex with an in- degree of
Source diagram or notation
and at least one vertex with an out-degree of
Source diagram or notation
.
B.
A directed graph can have a valid topological sort if and only if it does not contain any directed cycles.
C.
If we reverse the direction of every single edge in a DAG, the topological sort sequence of the new reversed graph will remain exactly identical to the original graph's sequence.
D.
To find a topological sort using Depth-First Search (DFS), a vertex is added to the final ordering sequence the moment it is first discovered (at its discovery time
Source diagram or notation
).
E.
If a directed graph contains a single connected component, it is guaranteed to have exactly one unique topological sort.

A published solution is not available for this question yet.

Report a correction for Q24

Question 25 MSQ · 4.0 marks

In the standard Inversion Count problem, a pair of numbers in an array is called an **"inversion"** if a larger number appears before a smaller number. If we have the array
Source diagram or notation
, which pair of numbers forms a valid inversion?
A.
(4, 1)
B.
(8, 5)
C.
(8, 7)
D.
(7, 5)
E.
(5, 4)

A published solution is not available for this question yet.

Report a correction for Q25

Question 26 MSQ · 4.0 marks

Which of the following denote non-polynomial time complexity?
A.Source diagram or notation
B.Source diagram or notation
C.Source diagram or notation
D.Source diagram or notation
E.Source diagram or notation

A published solution is not available for this question yet.

Report a correction for Q26