uiz Space

January 2026 term · Programming in Python · BSCS1002

Programming in Python End Term: 10 May 2026, Set 2 (January 2026 term)

The IIT Madras BS Programming in Python (Python) End Term paper sat on 10 May 2026, in the January 2026 term, set 2: 24 questions for 52 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
24
Marks
52
Duration
180 min
Written
7
MCQ
15
MSQ
2

Updated

Official paper: Programming In Python 06 May 26 · No negative marking.

Question 1

+4 marksWritten answer

Consider the following function:

If the function is called as: What value will the function return?

Consider the following function:
Show answer

A written answer, not marked automatically.

Question 2

+4 marksWritten answer

In a binary tree, the total number of nodes is 28. It is known that 10 nodes have exactly two children. How many nodes have exactly one child?

Show answer

A written answer, not marked automatically.

Question 3

+4 marksWritten answer

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 __.

Show answer

A written answer, not marked automatically.

Question 4

+4 marksWritten answer

An entire message is created using characters from the set The probability of occurrence of each character is given in the table below.

How many bits will be used to encode the message ABCDE using Huffman codes?

An entire message is created using characters from the set  The probability of occurrence of each character is given in
Show answer

A written answer, not marked automatically.

Question 5

+4 marksWritten answer

In a list , two elements and form a significant inversion if and . The total number of significant inversions for is ___ .

Show answer

A written answer, not marked automatically.

Question 6

+4 marksOne correct option

Arrange the above functions in increasing order of asymptotic complexity.

  1. A

    —

  2. B

    —

  3. C

    —

  4. D

    —

Show answer

Correct answer

  • D

    —

Question 7

+4 marksOne correct option

A list of strings, each of length is sorted in lexicographical order using the Merge Sort algorithm. What is its time complexity? (Assume that comparing strings lexicographically takes )

  1. A

    —

  2. B

    —

  3. C

    —

  4. D

    —

Show answer

Correct answer

  • B

    —

Question 8

+4 marksOne correct option

Consider that Quick sort is applied on a list of size which is sorted 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.

  1. A

    and

  2. B

    and

  3. C

    and

  4. D

    and

Show answer

Correct answer

  • B

    and

Question 9

+4 marksOne correct option

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: Insertion of a new node at the first position of the linked list1. Insertion of a new node at the last position of the linked list2. Deletion of the first node of the linked list3. Deletion of the last node of the linked list4. Using the most efficient algorithm, which of the following options correctly represents the time complexity of the above operations respectively?

Consider the following class  :
Consider the following class  :
  1. A

    —

  2. B

    —

  3. C

    —

  4. D

    —

Show answer

Correct answer

  • B

    —

Question 10

+4 marksOne correct option

Consider the following undirected graph .

Run BFS starting from vertex A. If multiple adjacent vertices exist, they are visited in alphabetical order. Which of the following is the correct BFS traversal order?

Consider the following undirected graph  .
  1. A

    A, B, D, E, C, F, G, H, I, J

  2. B

    A, B, D, E, F, C, G, H, I, J

  3. C

    A, B, C, H, J, G, D, E, F, I

  4. D

    A, B, D, E, C, F, H, G, I, J

Show answer

Correct answer

  • A

    A, B, D, E, C, F, G, H, I, J

Question 11

+4 marksOne correct option

Consider a connected, directed graph on which DFS is 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 a cross edge?

  1. A

    —

  2. B

    —

  3. C

    —

  4. D

    —

Show answer

Correct answer

  • A

    —

Question 12

+4 marksOne correct option

The Bellman-Ford algorithm cannot be used if a graph has negative cycles. This is because:

  1. A

    The algorithm only runs for n iterations, where n is the number of vertices.

  2. B

    The notion of the shortest path is not well-defined if there are negative cycles.

  3. C

    Dealing with negative cycles requires examining all paths exhaustively, which takes exponential time.

  4. D

    To handle negative cycles, we need to compute all-pairs shortest paths.

Show answer

Correct answer

  • B

    The notion of the shortest path is not well-defined if there are negative cycles.

Question 13

+4 marksOne correct option

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__.

  1. A

    1, 3, 8, 11

  2. B

    1, 3, 9, 11

  3. C

    2, 3, 9, 11

  4. D

    1, 2, 8, 11

Show answer

Correct answer

  • A

    1, 3, 8, 11

Question 14

+4 marksOne correct option

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 the minimum lateness across all possible schedules?

Consider the following activities  .
  1. A

    2

  2. B

    3

  3. C

    4

  4. D

    5

Show answer

Correct answer

  • C

    4

Question 15

+4 marksOne correct option

Consider the following recurrence relation for an algorithm: with base case . The complexity of this algorithm is ___

  1. A

    —

  2. B

    —

  3. C

    —

  4. D

    —

Show answer

Correct answer

  • C

    —

Question 16

+4 marksOne correct option

Consider four matrices and of dimensions and respectively. If and , then which of the following takes the least time for computation?

  1. A

    —

  2. B

    —

  3. C

    —

  4. D

    —

Show answer

Correct answer

  • D

    —

Question 17

+4 marksOne correct option

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?

  1. A

    It can be modelled as a network flow problem, where the source node is connected to every teacher node in with capacity of n, and every subject node in is connected to the sink node with capacity of 2n.

  2. B

    It can be modelled as a network flow problem, where the source node is connected to every teacher node in G, and every subject node in is connected to the sink node. All edges in the network flow graph have equal capacity.

  3. C

    It can be modelled as a network flow problem, where the source node is connected to every teacher node in with capacity of 2, and every subject node in is connected to the sink node with capacity of 1.

  4. D

    It can be modelled as a network flow problem, where the source node is connected to every teacher node in with capacity of 1, and every subject node in is connected to the sink node with capacity of 2.

Show answer

Correct answer

  • C

    It can be modelled as a network flow problem, where the source node is connected to every teacher node in with capacity of 2, and every subject node in is connected to the sink node with capacity of 1.

Question 18

+4 marksOne correct option

A factory produces two types of gadgets A and B. The profit earned is Rs. 6 per unit of A and Rs. 4 per unit of B. Each gadget must be processed on two machines M and N. One unit of A requires 2 minutes on machine M and 1 minute on machine N.• One unit of B requires 1 minute on machine M and 2 minutes on machine N.• Machine M is available for 6 hours (360 minutes) per day and machine N is available for 7 hours (420 minutes) per day. Which of the following is the correct Linear Programming formulation to maximize profit? Let be the number of units of type A and be the number of units of type B.

  1. A

    Maximize: Subject to:

  2. B

    Maximize: Subject to:

  3. C

    Maximize: Subject to:

  4. D

    Maximize: Subject to:

Show answer

Correct answer

  • A

    Maximize: Subject to:

Question 19

+4 marksOne correct option

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 ?

  1. A

    65

  2. B

    90

  3. C

    15

  4. D

    35

Show answer

Correct answer

  • C

    15

Question 20

+5 marksOne or more correct options

A hash table of size 10 uses open addressing with linear probing and the hash function After inserting 6 keys into an empty hash table, the final table is:

Which of the following could be possible insertion orders that produce this table?

A hash table of size 10 uses open addressing with linear probing and the hash function  After inserting 6 keys into an e

Select all that apply.

  1. A

    21, 32, 27, 12, 31, 40, 25

  2. B

    21, 32, 27, 12, 25, 31, 40

  3. C

    40, 32, 21, 25, 31, 12, 17

  4. D

    40, 32, 21, 25, 31, 27, 12

Show answer

Correct answers

  • A

    21, 32, 27, 12, 31, 40, 25

  • D

    40, 32, 21, 25, 31, 27, 12

Question 21

+5 marksWritten answer

A technology training institute offers an advanced certification program consisting of 10 modules. The program is divided into terms of 4 months. Students may enroll in any number of modules in a term, but a module can only be taken after completing all of its prerequisite modules. The prerequisite structure is given below.

There is no restriction on the number of modules a student can take in a term. The minimum number of terms required to complete all 10 modules is ___.

A technology training institute offers an advanced certification program consisting of 10 modules. The program is divide
Show answer

A written answer, not marked automatically.

Question 22

+5 marksWritten answer

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.

Show answer

A written answer, not marked automatically.

Question 23

+5 marksOne correct option

Consider the following graph.

Which of the following options correctly represents the shortest distances from node 0 to nodes (1, 2, 3, 4, 5) respectively?

Consider the following graph.
  1. A

    3, 2, 5, 9, 8

  2. B

    4, 2, 6, 9, 8

  3. C

    3, 2, 5, 8, 7

  4. D

    3, 2, 5, 7, 8

Show answer

Correct answer

  • C

    3, 2, 5, 8, 7

Question 24

+4 marksOne or more correct options

Consider the graph G given below.

Let Minimum 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/are correct?

Consider the graph G given below.

Select all that apply.

  1. A

    The total weight of every MST is 10

  2. B

    The total weight of every MST is 11

  3. C

    The edge (d, e) will not be part of any MST

  4. D

    The edge (b, e) will be part of every MST

  5. E

    The number of distinct MSTs in the graph is 2

Show answer

Correct answers

  • A

    The total weight of every MST is 10

  • C

    The edge (d, e) will not be part of any MST

  • D

    The edge (b, e) will be part of every MST