All mock tests are FREE till 31 December — register to save your progress
UGC NET · PAPER 2

UGC NET Paper 2 Computer Science – Unit 7: Data Structures and Algorithms PYQ (December 2022 Shift 1)

15 questions · answer key at the end · updated 11 Oct 2026
Q25. In a ______ the left and right subtrees of some node differ in height by more than one.
  1. Balanced binary tree
  2. Weight-balanced binary tree
  3. Height-balanced tree
  4. Unbalanced binary tree
Answer & explanation →
Q26. FFTs are ______ techniques used to encode digital video and audio information and help analyse the signal in the ____ domain.
  1. Encryption, time
  2. Encryption, frequency
  3. Compression, time
  4. Compression, frequency
Answer & explanation →
Q27. Given six weights 4, 15, 25, 5, 8, 16, construct a 2-tree (extended binary tree) with minimum weighted path length. What is the minimum weighted path length?
  1. 231
  2. 172
  3. 73
  4. 77
Answer & explanation →
Q28. Suppose we store n keys in a hash table of size m = n² using a hash function h chosen randomly from a universal class of hash functions. Then the probability that there are any collisions is ______
  1. greater than 1/5
  2. greater than 1/2
  3. less than 1/2
  4. less than 1/5
Answer & explanation →
Q56. Which of the following rotations are correctly explained in the context of an AVL tree?
A. LL rotation: the new node is inserted in the left subtree of the left subtree of the critical node.
B. RR rotation: the new node is inserted in the right subtree of the right subtree of the critical node.
C. LR rotation: the new node is inserted in the right subtree of the left subtree of the critical node.
D. RL rotation: the new node is inserted in the left subtree of the right subtree of the critical node.
Choose the correct answer from the options given below:
  1. A, D only
  2. A, C Only
  3. A, B, C and D
  4. B, C Only
Answer & explanation →
Q57. In the context of Hamiltonian problems, which of the following are correct?
A. The Hamiltonian cycle problem is NP-complete.
B. If G is an undirected bipartite graph with an odd number of vertices, then G is Hamiltonian.
C. The Hamiltonian path problem cannot be solved in polynomial time on a directed acyclic graph.
D. If G is a connected undirected graph with at least three vertices, then G³ (the graph obtained by connecting all pairs of vertices joined by a path of length at most 3 in G) is Hamiltonian.
E. If any NP-complete problem is polynomial-time solvable, then P = NP.
Choose the most appropriate answer from the options given below:
  1. A, B, C only
  2. B, D, E only
  3. A, D, E only
  4. A, C, E only
Answer & explanation →
Q58. For matrix multiplication using the simple divide-and-conquer algorithm:
A. The running time is T(n) = Θ(n³)
B. The running time is T(n) = Θ(n² log n)
C. The recurrence is T(n) = 8T(n/2) + Θ(n²)
D. The recurrence is T(n) = 8T(2n) + Θ(n² log n)
E. One of the Master theorem cases is applicable
Choose the most appropriate answer from the options given below:
  1. A, C, E only
  2. A, D, E only
  3. B, D, E only
  4. B, C, D only
Answer & explanation →
Q66. Match List I with List II
List IList II
A. Linear ProgramI. Prim's Algorithm
B. Predicate LogicII. In order
C. Tree TraversalIII. Simplex Algorithm
D. Minimum Spanning Tree ProblemIV. First order logic
  1. A-IV; B-III; C-I; D-II
  2. A-III; B-IV; C-II; D-I
  3. A-II; B-IV; C-I; D-III
  4. A-III; B-IV; C-I; D-II
Answer & explanation →
Q72. Match List I with List II
List IList II
A. 8-Queens problemI. Divide and conquer
B. Closest pair of pointsII. Dynamic Programming
C. String edit problemIII. Greedy Method
D. Knapsack problemIV. Backtracking
  1. A-I, B-II, C-III, D-IV
  2. A-I, B-IV, C-II, D-III
  3. A-IV, B-I, C-II, D-III
  4. A-II, B-III, C-IV, D-I
Answer & explanation →
Q78. Arrange the following search and sort algorithms in ascending order of their worst-case complexities:
A. Merge sort
B. Linear search
C. Bubble sort
D. Binary search
Choose the correct answer from the options given below:
  1. D, B, A, C
  2. B, D, A, C
  3. B, D, C, A
  4. B, A, D, C
Answer & explanation →

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Q91. Find the optimal solution of the fractional knapsack problem when the maximum capacity is 15.
  1. 43
  2. 40
  3. 45
  4. 44
Answer & explanation →
Q92. What is the maximum value of the items you can carry if the maximum weight allowed is 25 (fractional knapsack)?
  1. 48.1
  2. 49
  3. 47.9
  4. 40
Answer & explanation →
Q93. If a new item (P = 5, W = 2) is added, giving 8 items, and the capacity is 25, then the time of fractional knapsack in this case is ______
  1. O(8)
  2. O(64)
  3. O(24)
  4. O(56)
Answer & explanation →
Q94. The most efficient solution to the fractional knapsack problem with maximum capacity 15 is obtained using ___
  1. Divide and Conquer
  2. Dynamic Programming
  3. Greedy Algorithm
  4. Backtracking
Answer & explanation →
Q95. Which of the following statements about the knapsack problem is correct?
  1. 0/1 knapsack can be applied to all kinds of problems, but fractional knapsack only if the problem meets certain conditions.
  2. There is no difference between the two; they give the same solution for any problem.
  3. We use the greedy algorithm for 0/1 knapsack and dynamic programming for fractional knapsack.
  4. In the 0/1 knapsack problem items cannot be divided into smaller portions, while in the fractional knapsack items can be divided in any proportion.
Answer & explanation →

Answer key

  1. 25 – D
  2. 26 – D
  3. 27 – B
  4. 28 – C
  5. 56 – C
  6. 57 – C
  7. 58 – A
  8. 66 – B
  9. 72 – C
  10. 78 – A
  11. 91 – B
  12. 92 – A
  13. 93 – C
  14. 94 – C
  15. 95 – D