uiz Space

January 2024 term · Programming, Data Structures and Algorithms using Python · BSCS2002

Programming, Data Structures and Algorithms using Python Quiz 2: 24 March 2024 (January 2024 term)

The IIT Madras BS Programming, Data Structures and Algorithms using Python (PDSA) Quiz 2 paper sat on 24 Mar 2024, in the January 2024 term: 16 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
16
Marks
50
Duration
120 min
MCQ
8
MSQ
4
Numerical
4

Updated

Official paper: IIT M DIPLOMA AN EXAM QDD2 24 Mar 2024 · No negative marking.

Question 1

+2 marksOne correct option

In the context of the Floyd-Warshall algorithm, what does it mean if the distance matrix has a negative value in its diagonal?

  1. A

    The graph has a negative-weight cycle.

  2. B

    The graph has negative-weight on edge but no negative-weight cycle.

  3. C

    The graph is acyclic.

  4. D

    The graph has a disconnected component.

Show answer

Correct answer

  • A

    The graph has a negative-weight cycle.

Question 2

+3 marksOne correct option
  1. A

    P, Q, R, U, T, S

  2. B

    P, Q, R, S, T, U

  3. C

    P, Q, R, S, U, T

  4. D

    P, Q, R, U, S, T

Show answer

Correct answer

  • D

    P, Q, R, U, S, T

Question 3

+3 marksOne correct option

You have a max-heap with the following set of elements:
{10, 5, 15, 3, 8, 12}
Which of the following elements is guaranteed to be a child of the element 15?

  1. A

    10

  2. B

    5

  3. C

    12

  4. D

    8

Show answer

Correct answer

  • C

    12

Question 4

+3 marksOne correct option

Consider the following sequence of numbers inserted into an empty Binary Search Tree(BST): 50, 30, 20, 40, 70, 60, 80, 35
What will be the height of the resulting BST? Consider that the height of empty binary search tree is 0.

  1. A

    3

  2. B

    4

  3. C

    5

  4. D

    6

Show answer

Correct answer

  • B

    4

Question 5

+3 marksOne correct option

Which of the following traversals would visit the nodes of a binary search tree in the following order?
10, 5, 3, 8, 15, 12, 20

  1. A

    In-order traversal

  2. B

    Pre-order traversal

  3. C

    Post-order traversal

Show answer

Correct answer

  • B

    Pre-order traversal

Question 6

+3 marksOne correct option

Apply the divide and conquer strategy to find the closest pair of points in a set. After dividing the set into two halves and recursively finding the closest pairs in each half, what additional step is required?

  1. A

    Combine the results directly

  2. B

    Perform a linear search for the closest pair

  3. C

    Consider pairs that span both halves

  4. D

    Sort the points by their distances

Show answer

Correct answer

  • C

    Consider pairs that span both halves

Question 7

+3 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 8

+4 marksOne correct option
  1. A

    a, e, b, c, d, g, h, f

  2. B

    a, e, b, c, g, h, d, f

  3. C

    a, e, b, d, c, h, g, f

  4. D

    a, e, b, d, c, g, f, h

Show answer

Correct answer

  • A

    a, e, b, c, d, g, h, f

Question 9

+2 marksOne or more correct options

For a set of symbols with probabilities of occurrence, which of the following statement(s) about the Huffman tree is/are correct?

Select all that apply.

  1. A

    Symbols with higher probabilities are generally closer to the root of the tree

  2. B

    Symbols with lower probabilities are generally closer to the root of the tree

  3. C

    The Huffman tree is always a complete binary tree

  4. D

    It generates prefix codes (no code is a prefix of another).

Show answer

Correct answers

  • A

    Symbols with higher probabilities are generally closer to the root of the tree

  • D

    It generates prefix codes (no code is a prefix of another).

Question 10

+3 marksOne or more correct options

Define the slope of a node as the absolute difference in height between the left subtree and the right subtree of the node. Consider that the height of the empty tree is 0.
Consider the below AVL Tree.

After inserting 19 in the given AVL tree (before applying rotation), which of the following node's slopes will become greater than 1? Select all that are correct.

Select all that apply.

  1. A

    38

  2. B

    56

  3. C

    14

  4. D

    18

  5. E

    23

Show answer

Correct answers

  • C

    14

  • E

    23

Question 11

+3 marksOne or more correct options

Consider the following statements and choose the correct ones.

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • C

Question 12

+4 marksOne or more correct options

Select all that apply.

  1. A

    If all given weights are distinct, then only one unique MST is possible.

  2. B

    If w1 and w2 are the same and largest among all weights and other weights are distinct, then only one unique MST is possible.

  3. C

    If w1 and w3 are the same and largest among all weights and other weights are distinct, then only one unique MST is possible.

  4. D

    If w1 and w4 are the same and smallest among all weights and other weights are distinct, then only one unique MST is possible.

Show answer

Correct answers

  • A

    If all given weights are distinct, then only one unique MST is possible.

  • C

    If w1 and w3 are the same and largest among all weights and other weights are distinct, then only one unique MST is possible.

  • D

    If w1 and w4 are the same and smallest among all weights and other weights are distinct, then only one unique MST is possible.

Question 13

+3 marksNumerical answer

Consider a binary tree with 21 nodes. The maximum number of leaves possible in tree is ___________.

Show answer

Correct answer: 11

Question 14

+3 marksNumerical answer
Show answer

Correct answer: 16

Question 15

+4 marksNumerical answer
Show answer

Correct answer: 5

Question 16

+4 marksNumerical answer
Show answer

Correct answer: 4