Preparing your form...
|Data Structures and Algorithms PYQs

UGC NET Computer Science Data Structures and Algorithms Previous Year Questions (PYQs)

Practise 143 Data Structures and Algorithms questions asked in UGC NET Computer Science from 2018–2026. Questions cover Arrays, Trees, Graphs, Hashing, Sorting and searching algorithms with complexity analysis and Asymptotic notation and solving recurrence relations. Every question is shown with its options and the correct answer, free to read.

143 PYQs2018–2026Answers includedFree

Practise Data Structures and Algorithms as timed sets

Focused 10-question sets with instant scoring, explanations, and weak-area analysis.

Start practice

All 143 Data Structures and Algorithms PYQs

Ordered newest exam first. Each question links back to the full paper it came from.

  1. What is the maximum number of nodes that can be inserted in the AVL tree without changing its height?

    AVL tree with nodes 60, 50, 70, and 80.

    AVL tree with nodes 60, 50, 70, and 80.

    1. A2
    2. B4
    3. C3
    4. D5

    Answer: (C) 3

    Explanation

    Sign in to read the full explanation
  2. Match List-I with List-II.

    List-IList-II
    A. Merge sort
    B. Binary search
    C. Quick sort
    D. Search in an unsorted array
    I. n²
    II. n log n
    III. n
    IV. log n
    1. AA-I, B-IV, C-II, D-III
    2. BA-I, B-II, C-III, D-IV
    3. CA-II, B-I, C-III, D-IV
    4. DA-II, B-IV, C-I, D-III

    Answer: (D) A-II, B-IV, C-I, D-III

    Explanation

    Sign in to read the full explanation
  3. The number of leaf nodes in a full 4-ary rooted tree with n nodes is:

    1. An/2
    2. B(2n − 1)/4
    3. C(n + 1)/4
    4. D(3n + 1)/4

    Answer: (D) (3n + 1)/4

    Explanation

    Sign in to read the full explanation
  4. A problem of size n requires n² bit operations. What is the largest instance that can be solved in one second if each bit operation takes 10⁻⁹ second?

    1. A10⁹
    2. B3.16 × 10⁴
    3. C3.96 × 10⁷
    4. D2 × 10⁹

    Answer: (B) 3.16 × 10⁴

    Explanation

    Sign in to read the full explanation
  5. Match List-I with List-II.

    A. Stack
    B. Queue
    C. Linked list
    D. Binary search tree

    List-IList-II
    A. Stack
    B. Queue
    C. Linked list
    D. Binary search tree
    I. FIFO
    II. LIFO
    III. Ordered children
    IV. Sequentially linked dynamic nodes
    1. AA-IV, B-I, C-II, D-III
    2. BA-II, B-I, C-IV, D-III
    3. CA-III, B-IV, C-I, D-II
    4. DA-II, B-I, C-III, D-IV

    Answer: (B) A-II, B-I, C-IV, D-III

    Explanation

    Sign in to read the full explanation
  6. In the worst case, the smallest number of comparisons required by a comparison-based sorting algorithm is:

    1. A⌈log n⌉
    2. B⌈log₂(n!)⌉
    3. C⌈log n(n − 1)⌉
    4. Dn

    Answer: (B) ⌈log₂(n!)⌉

    Explanation

    Sign in to read the full explanation
  7. What is the height of the binary search tree formed by inserting 40, 60, 50, 37, 52, 15, 8, 22 in that order?

    1. A4
    2. B3
    3. C2
    4. D1

    Answer: (B) 3

    Explanation

    Sign in to read the full explanation
  8. How will the shown min-heap appear after inserting key 32?

    Original min-heap and the four candidate heaps after insertion.

    Original min-heap and the four candidate heaps after insertion.

    1. AOption 1
    2. BOption 2
    3. COption 3
    4. DOption 4

    Answer: (C) Option 3

    Explanation

    Sign in to read the full explanation
  9. If f(n) = θ(g(n)) and g(n) = O(h(n)), which statement is true?

    1. Af(n) = O(h(n))
    2. Bf(n) = θ(h(n))
    3. Ch(n) = O(f(n))
    4. Dh(n) = θ(f(n))

    Answer: (A) f(n) = O(h(n))

    Explanation

    Sign in to read the full explanation
  10. A BST is formed by inserting Mathematics, Physics, Geography, Zoology, Metrology, Geology, Psychology, and Chemistry in dictionary order. Arrange these words in increasing order of their tree level:

    A. Mathematics
    B. Zoology
    C. Psychology
    D. Physics

    1. AA, D, C, B
    2. BA, C, D, B
    3. CA, D, B, C
    4. DC, B, D, A

    Answer: (C) A, D, B, C

    Explanation

    Sign in to read the full explanation
  11. In open addressing, how are collisions typically resolved?

    1. ABy probing to find the next available table slot
    2. BBy creating a linked list at the collision point
    3. CBy rehashing the entire table
    4. DBy storing colliding elements in a separate array

    Answer: (A) By probing to find the next available table slot

    Explanation

    Sign in to read the full explanation
  12. The inorder and preorder traversal of a binary tree are d, b, e, a, f, c, g and a, b, d, e, c, f, g respectively. The postorder traversal of the binary tree is

    1. Ad, e, b, f, g, c, a
    2. Be, d, b, g, f, c, a
    3. Ce, d, b, f, g, c, a
    4. Dd, e, f, g, b, c, a

    Answer: (A) d, e, b, f, g, c, a

    Explanation

    Sign in to read the full explanation
  13. How many comparisons are required in the worst case to find the second smallest element of a list of n elements?

    1. An + ⌈log n⌉ − 1
    2. Bn + ⌈log n⌉
    3. C⌈log n⌉
    4. Dn + ⌈log n⌉ − 2

    Answer: (D) n + ⌈log n⌉ − 2

    Explanation

    Sign in to read the full explanation
  14. Arrange the following prefix expressions in ascending order on the basis of their values.

    A. − * 2 / 8 4 3
    B. ↑ − * 3 6 * 4 2 5
    C. + − ↑ 3 2 ↑ 2 3 / 6 − 4 2
    D. * + 3 + 3 ↑ 3 + 1 1 3

    1. AA, D, C, B
    2. BA, C, D, B
    3. CA, B, C, D
    4. DC, A, D, B

    Answer: (B) A, C, D, B

    Explanation

    Sign in to read the full explanation
  15. Match List-I (Algorithm design techniques) with List-II.

    List-IList-II
    A. Dynamic programmingI. Floyd Warshall shortest path
    B. GreedyII. Huffman coding
    C. Back trackingIII. Hamiltonian cycle problem
    D. Branch and boundIV. Travelling salesman (TSP) using lower bound
    1. AA-II, B-III, C-IV, D-I
    2. BA-IV, B-III, C-II, D-I
    3. CA-I, B-II, C-III, D-IV
    4. DA-III, B-IV, C-I, D-II

    Answer: (C) A-I, B-II, C-III, D-IV

    Explanation

    Sign in to read the full explanation
  16. Which of the following statements about DFS are correct?
    A. It can detect cycles in a graph.
    B. It can be used to find connected components.
    C. It works for both directed and undirected graphs.
    D. Guarantees shortest path in unweighted graphs.

    1. AA, B, C Only
    2. BA, B, C, D
    3. CC, D Only
    4. DB, C Only

    Answer: (A) A, B, C Only

    Explanation

    Sign in to read the full explanation
  17. Assertion (A): Kruskal's algorithm and Prim's algorithm always produce a minimum spanning tree (MST).
    Reason (R): Every connected graph has a unique MST.

    1. ABoth A and R are correct and R is the correct explanation of A
    2. BBoth A and R are correct but R is NOT the correct explanation of A
    3. CA is correct but R is not correct
    4. DA is not correct but R is correct

    Answer: (C) A is correct but R is not correct

    Explanation

    Sign in to read the full explanation
  18. Which of the following is the correct order of increasing time complexity of the given algorithms?
    A. Tower of Hanoi with n disks
    B. Binary search given n sorted numbers
    C. Heap sort given n numbers, worst case
    D. Addition of two n × n matrices

    1. AB, C, D, A
    2. BA, B, C, D
    3. CD, C, B, A
    4. DC, A, D, B

    Answer: (A) B, C, D, A

    Explanation

    Sign in to read the full explanation
  19. Which of the following is the correct solution of the given recurrence relation?

    T(n) = 3T(n/4) + n log n

    1. Aθ(n log n)
    2. Bθ(n² log n)
    3. Cθ(n(log n)²)
    4. Dθ(n log log n)

    Answer: (A) θ(n log n)

    Explanation

    Sign in to read the full explanation
  20. Arrange the following algorithms from the most efficient to the least efficient based on their time complexity.

    A. Kruskal's Algorithm
    B. Breadth First Search Algorithm
    C. Bellman-Ford Algorithm
    D. Dijkstra's Algorithm
    E. Edmonds-Karp Algorithm

    1. AB, D, A, E, C
    2. BE, C, A, D, B
    3. CB, D, A, C, E
    4. DB, C, A, E, D

    Answer: (C) B, D, A, C, E

    Explanation

    Sign in to read the full explanation
  21. Match List-I (Algorithms) with List-II (Real-world applications).

    List-IList-II
    A. Dijkstra's AlgorithmI. GPS route finding
    B. Huffman CodingII. Data compression
    C. KMP String MatchingIII. Text editor search function
    D. Ford-FulkersonIV. Network bandwidth optimization
    1. AA-II, B-IV, C-I, D-III
    2. BA-I, B-II, C-III, D-IV
    3. CA-IV, B-II, C-III, D-I
    4. DA-IV, B-III, C-II, D-I

    Answer: (B) A-I, B-II, C-III, D-IV

    Explanation

    Sign in to read the full explanation
  22. Which of the following are limitations of Greedy algorithms?

    A. They always fail for NP hard problem.
    B. They may not give the optimal solution for all problems.
    C. They are faster than dynamic programming in most cases.
    D. They make local choices without looking ahead.

    1. AA, C Only
    2. BB, C Only
    3. CA, B, C, D
    4. DB, D Only

    Answer: (D) B, D Only

    Explanation

    Sign in to read the full explanation
  23. Assertion (A): Depth first search can be used to perform a topological sort of a directed acyclic graph.
    Reason (R): A topological sort of a directed acyclic graph with vertex set V and edge set E is a linear ordering of its vertices such that if the graph contains an edge from u to v, then u appears before v in the ordering.

    1. ABoth A and R are correct and R is the correct explanation of A
    2. BBoth A and R are correct but R is NOT the correct explanation of A
    3. CA is correct but R is not correct
    4. DA is not correct but R is correct

    Answer: (A) Both A and R are correct and R is the correct explanation of A

    Explanation

    Sign in to read the full explanation
  24. For infix expression ((A+B)*D)↑(E-F), what is its equivalent postfix expression?

    1. AA B + D * E F ↑
    2. BA B + D * - ↑ E F
    3. CA B + D E * F - ↑
    4. DA B + D * E F - ↑

    Answer: (D) A B + D * E F - ↑

    Explanation

    Sign in to read the full explanation
  25. What is the tight asymptotic bound for T(n) = 2T(n/4) + √n?

    1. AΘ(√n)
    2. BΘ(n log n)
    3. CΘ(√n log n)
    4. DΘ(n log √n)

    Answer: (C) Θ(√n log n)

    Explanation

    Sign in to read the full explanation
  26. Practise Data Structures and Algorithms in a timed set
  27. Which sequence is a longest common subsequence of {1, 2, 3, 2, 4, 1, 2} and {2, 4, 3, 1, 2, 1}?

    1. A2, 1, 2, 3
    2. B1, 3, 2, 1
    3. C2, 3, 2, 1
    4. D2, 3, 1, 2, 1

    Answer: (C) 2, 3, 2, 1

    Explanation

    Sign in to read the full explanation
  28. Maintaining a graph in memory using its adjacency matrix is called:

    1. AComplete representation
    2. BLinked representation
    3. CCircular representation
    4. DSequential representation

    Answer: (D) Sequential representation

    Explanation

    Sign in to read the full explanation
  29. To construct a Huffman tree, first create leaf nodes, build a priority queue, repeatedly combine the lowest-frequency nodes, and stop when the root is formed. Which sequence is correct?

    1. AB, C, A, D
    2. BD, B, A, C
    3. CB, C, D, A
    4. DC, A, B, D

    Answer: (C) B, C, D, A

    Explanation

    Sign in to read the full explanation
  30. In dynamic programming, the steps are characterizing an optimal solution, recursively defining its value, computing that value bottom-up, and constructing an optimal solution. Which sequence is correct?

    1. AB, C, A, D
    2. BB, A, C, D
    3. CC, B, A, D
    4. DC, B, D, A

    Answer: (D) C, B, D, A

    Explanation

    Sign in to read the full explanation
  31. Which algorithms use a greedy strategy: Dijkstra's algorithm, Kruskal's algorithm, Huffman coding, and Bellman-Ford?

    1. AA, B, and D only
    2. BA, B, and C only
    3. CC and D only
    4. DA and D only

    Answer: (B) A, B, and C only

    Explanation

    Sign in to read the full explanation
  32. Which trees are height balanced: binary search tree, AVL tree, red-black tree, and B-tree?

    1. AA and D only
    2. BA, B, and D only
    3. CC and D only
    4. DB and C only

    Accepted answers: (C) C and D only, (D) B and C only

    Explanation

    Sign in to read the full explanation
  33. Match circular queue, priority queue, deque, and simple queue with their common applications.

    List IList II
    A. Circular QueueI. Print Queue
    B. Priority QueueII. CPU Scheduling
    C. Double Ended QueueIII. Dijkstra algorithm
    D. Simple QueueIV. Palindrome checking
    1. AA-II, B-III, C-I, D-IV
    2. BA-II, B-III, C-IV, D-I
    3. CA-III, B-II, C-I, D-IV
    4. DA-IV, B-II, C-I, D-III

    Answer: (B) A-II, B-III, C-IV, D-I

    Explanation

    Sign in to read the full explanation
  34. Match chaining, linear probing, quadratic probing, and double hashing with their collision-handling strategies.

    MethodStrategy
    A. ChainingI. Check next slot
    B. Linear ProbingII. Use second hash function
    C. Quadratic ProbingIII. Linked list at index
    D. Double HashingIV. Quadratic step
    1. AA-II, B-III, C-I, D-IV
    2. BA-II, B-III, C-IV, D-I
    3. CA-III, B-I, C-IV, D-II
    4. DA-IV, B-II, C-I, D-III

    Answer: (C) A-III, B-I, C-IV, D-II

    Explanation

    Sign in to read the full explanation
  35. Which of the following uses only increment operations for adding and removing elements at either end?

    1. AQueues
    2. BStacks
    3. CPriority queues
    4. DDeques

    Answer: (D) Deques

    Explanation

    Sign in to read the full explanation
  36. Match List-I with List-II.

    List-IList-II
    A. Breadth-first search
    B. Depth-first search
    C. Prefix
    D. Infix
    I. LISP
    II. Syntax tree
    III. Stack
    IV. Queue
    1. AA-III, B-IV, C-I, D-II
    2. BA-III, B-IV, C-II, D-I
    3. CA-IV, B-II, C-III, D-I
    4. DA-IV, B-III, C-I, D-II

    Answer: (D) A-IV, B-III, C-I, D-II

    Explanation

    Sign in to read the full explanation
  37. Which descriptions are true?

    A. Red-black tree guarantees O(log n) worst-case search, insertion and deletion.
    B. Trie supports efficient prefix-based searches.
    C. AVL tree is a self-balancing binary search tree with stricter balance criteria.
    D. B-tree supports efficient disk-based search, insertion and deletion.

    1. AA and B only
    2. BC and D only
    3. CB only
    4. DA, B and D only

    Answer: (D) A, B and D only

    Explanation

    Sign in to read the full explanation
  38. Which of the following is not a divide-and-conquer method?

    1. ABinary search
    2. BMerge sort
    3. CQuick sort
    4. DHeap sort

    Answer: (D) Heap sort

    Explanation

    Sign in to read the full explanation
  39. Match List-I with List-II.

    List-IList-II
    A. Insertion sort
    B. Binary search
    C. Quick sort
    D. Selection sort
    I. O(log n)
    II. O(n²)
    III. O(n−1)
    IV. O(n log n)
    1. AA-III, B-I, C-IV, D-II
    2. BA-II, B-III, C-I, D-IV
    3. CA-I, B-II, C-IV, D-III
    4. DA-II, B-III, C-IV, D-I

    Answer: (A) A-III, B-I, C-IV, D-II

    Explanation

    Sign in to read the full explanation
  40. Considering the binary tree shown, what will be the inorder traversal?

    NodeLeft childRight child
    ABC
    CDE
    E—F
    FGH
    1. AB A D C E G F H
    2. BG H F E D C B A
    3. CB A C D E G F H
    4. DG H F D E B C A

    Answer: (A) B A D C E G F H

    Explanation

    Sign in to read the full explanation
  41. Which of the following is the solution of the recurrence relation T(n) = T(2n/3) + 1?

    1. AΘ(n²)
    2. BΘ(log n)
    3. CΘ(n log n)
    4. DΘ(n³⁄²)

    Answer: (B) Θ(log n)

    Explanation

    Sign in to read the full explanation
  42. Arrange the steps of inorder traversal of a binary tree.

    A. Visit the left subtree.
    B. Visit the root node.
    C. Visit the right subtree.
    D. Start traversing by visiting nodes in the rooted tree.
    E. Repeat the above three steps.

    1. AA, B, C, D, E
    2. BE, A, B, C, D
    3. CD, A, B, C, E
    4. DD, A, E, B, C

    Answer: (C) D, A, B, C, E

    Explanation

    Sign in to read the full explanation
  43. Which of the following algorithms are based on breadth-first search (BFS)?

    A. Prim’s algorithm
    B. Kruskal’s algorithm
    C. Dijkstra’s algorithm
    D. Greedy algorithm
    E. Dynamic programming

    1. AA and B only
    2. BA, C and D only
    3. CD and E only
    4. DA and C only

    Answer: (D) A and C only

    Explanation

    Sign in to read the full explanation
  44. Arrange the following recurrence relations in increasing order of their time complexity:

    A. T(n) = T(n/2) + 1
    B. T(n) = 2T(n/2) + n
    C. T(n) = 3T(n/3) + n
    D. T(n) = 2T(n/2) + √n
    E. T(n) = T(n−1) + 1

    Choose the correct answer from the options given below:

    1. A(E), (A), (B), (D), (C)
    2. B(A), (E), (D), (B), (C)
    3. C(E), (A), (D), (B), (C)
    4. D(A), (B), (D), (E), (C)

    Answer: (B) (A), (E), (D), (B), (C)

    Explanation

    Sign in to read the full explanation
  45. Match List-I with List-II.

    List-I (Algorithms)List-II (Characteristics)
    (A) First Come First Served (FCFS)(I) Each process is assigned a priority.
    (B) Shortest Job First (SJF)(II) Ensures fair allocation of CPU time by assigning time slice.
    (C) Round Robin (RR)(III) Processes are executed in the order they arrive.
    (D) Priority Scheduling(IV) Select the process for execution with smallest next Burst time.
    1. A(A)-(II), (B)-(III), (C)-(IV), (D)-(I)
    2. B(A)-(II), (B)-(IV), (C)-(III), (D)-(I)
    3. C(A)-(III), (B)-(IV), (C)-(II), (D)-(I)
    4. D(A)-(III), (B)-(IV), (C)-(I), (D)-(II)

    Answer: (C) (A)-(III), (B)-(IV), (C)-(II), (D)-(I)

    Explanation

    Sign in to read the full explanation
  46. Select the Sorting Algorithms that are stable.
    A. Quick Sort
    B. Bubble Sort
    C. Insertion Sort
    D. Merge Sort
    E. Shell Sort

    1. A(A), (B), (C) and (E) Only
    2. B(A), (D) and (E) Only
    3. C(B) and (C) Only
    4. D(B), (C) and (D) Only

    Answer: (D) (B), (C) and (D) Only

    Explanation

    Sign in to read the full explanation
  47. ___________is a Self Balancing binary search
    tree, where the path from the root to the furthest
    leaf is no more than twice as long as the path
    from the root to nearest leaf.

    1. AExpression tree
    2. BGame tree
    3. CRed-Black tree
    4. DThreaded tree

    Answer: (C) Red-Black tree

    Explanation

    Sign in to read the full explanation
  48. Arrange the following steps in the correct order
    to solve the Knapsack problem using Dynamic
    Programming.
    A. Define the base case when the capacity is
    zero (0) or no items are left to consider
    B. Compute the maximum value that can be
    obtained using items up to the i-th item and a
    knapsack capacity of 0
    C. Identify subproblems and their dependencies
    based on items weights and values
    D. Initialize a table to store results of
    subproblems
    E. Iterate through each item and each possible
    Capacity to fill the table

    1. A(C), (D), (A), (E), (B)
    2. B(D), (C), (A), (E), (B)
    3. C(A), (C), (D), (E), (B)
    4. D(D), (A), (C), (E), (B)

    Answer: (C) (A), (C), (D), (E), (B)

    Explanation

    Sign in to read the full explanation
  49. Which of the following is not a palindromic subsequence of the string "ababcdabba" ?

    1. Aabcba
    2. Babba
    3. Cabbbba
    4. Dadba

    Answer: (D) adba

    Explanation

    Sign in to read the full explanation
  50. Which of the following is TRUE ?

    1. AThe cost of searching an AVL tree is @ (log n) but that of binary search is 0(n)
    2. BThe cost of searching an AVL tree in @ (log n) but that of complete binary tree is @ (n log n)
    3. CThe cost of searching a binary tree is O(log n) but that of AVL tree is @ (n)
    4. DThe cost of searching an AVL tree is @ (n log n) but that of binary search tree is 0(n)

    Answer: (A) The cost of searching an AVL tree is @ (log n) but that of binary search is 0(n)

    Explanation

    Sign in to read the full explanation
  51. What is the result of evaluating the postfix expression "4325+b—" ?

    1. A8
    2. B14
    3. C10
    4. D5

    Answer: (A) 8

    Explanation

    Sign in to read the full explanation
  52. Practise Data Structures and Algorithms in a timed set
  53. Which data structure is typically used to implement hash table ?

    1. ALinked list
    2. BArray
    3. CBinary Tree
    4. DStack

    Answer: (B) Array

    Explanation

    Sign in to read the full explanation
  54. Which collision resolution technique involves maintaining a linked list of collided keys ?

    1. ALinear probing
    2. BQuadratic probing
    3. CChaining
    4. DDouble hashing

    Answer: (C) Chaining

    Explanation

    Sign in to read the full explanation
  55. Consider the following functions : f(n) = anv g(n) = 2" log? h(n) =n! Which of the following is true ?

    1. Aht) is 0 (fm)
    2. Bh(n) is 0 (g(n))
    3. Cg(n) is not 0 (f(n))
    4. D£(m) is 0 (g(m))

    Answer: (D) £(m) is 0 (g(m))

    Explanation

    Sign in to read the full explanation
  56. 2-3-4 trees are B - trees of order 4. They are isometric of trees.

    1. AAVL
    2. BAA
    3. C2-3
    4. DRed-Black

    Answer: (D) Red-Black

    Explanation

    Sign in to read the full explanation
  57. Which of the following graphs are trees ? bs b @ d
    A. e f a b c d
    B. e f a b é d (9) e f a b c d
    D. e f Choose the correct answer from the options given below :

    1. A(A) and (B) Only
    2. B(A), (B) and (D) Only
    3. C(A) and (D) Only
    4. D(A), (B), (©) and (D) Only

    Answer: (A) (A) and (B) Only

    Explanation

    Sign in to read the full explanation
  58. Arrange the following steps in the correct sequence for applying an unsupervised learning technique such as K-means clustering is to a data set :
    A. Randomly initialize cluster centroids
    B. Assign each data point to nearest cluster centroid
    C. Update the cluster centroids based on the mean of data points assigned to each cluster
    D. Specify the number of clusters (K) to partation the data into
    E. Repeat steps B and C until convergence criteria are met Choose the correct answer from the options given below : @) (©),
    A. , ©, ©

    1. AD, A, B, C, E
    2. BA, B, C, D, E
    3. CC, B, A, D, E
    4. DD, C, A, B, E

    Answer: (A) D, A, B, C, E

    Explanation

    Sign in to read the full explanation
  59. Match List I with List II on algorithm running times.

    List IList II
    A. Parallel FFTI. Θ(n²)
    B. Iterative FFTII. Θ(n)
    C. Evaluation of polynomial at n points by Horner methodIII. Θ(lg n)
    D. Product of two polynomials that are represented in point value formIV. Θ(n lg n)

    List I to List II matching for FFT and polynomial algorithm running times

    1. AA-III, B-I, C-II, D-IV
    2. BA-II, B-I, C-III, D-IV
    3. CA-III, B-IV, C-I, D-II
    4. DA-II, B-III, C-IV, D-I

    Answer: (C) A-III, B-IV, C-I, D-II

    Explanation

    Sign in to read the full explanation
  60. Match List I with List II on Fibonacci computation running times.

    List IList II
    A. The running time of the straightforward recursive method to compute the nth Fibonacci number FnI. O(n²)
    B. The running time to compute Fn using memoizationII. O(lg n)
    C. The running time to compute a Fibonacci number Fn using only integer addition and multiplicationIII. O(n)
    D. The running time to determine an optimal bitonic tourIV. Θ(φⁿ)

    List I to List II matching for Fibonacci computation and bitonic tour running times

    1. AA-I, B-III, C-IV, D-II
    2. BA-IV, B-III, C-II, D-I
    3. CA-I, B-II, C-IV, D-III
    4. DA-IV, B-II, C-III, D-I

    Answer: (B) A-IV, B-III, C-II, D-I

    Explanation

    Sign in to read the full explanation
  61. A three-dimensional array in C++ is declared as int A[a][b][c]. Consider that array elements are stored in row-major order and indexing begins from 0. The address of an item at location A[r][s][t], computed in terms of the word length w of an integer, is

    1. A&A[0][0][0] + w (bcs + c*r + t)
    2. B&A[0][0][0] + w (bcr + c*s + t)
    3. C&A[0][0][0] + w (abr + c*s + t)
    4. D&A[0][0][0] + w (abs + c*r + t)

    Answer: (B) &A[0][0][0] + w (bcr + c*s + t)

    Explanation

    Sign in to read the full explanation
  62. Consider the following statements about heap sort algorithm:
    A. The MAX-HEAPIFY procedure which runs in O(lg n) time, is the key to maintaining the max heap property
    B. The BUILD-MAX-HEAP procedure, which runs in O(lg n) time, produces max-heap from an unordered input array
    C. The MAX-HEAP-INSERT, which runs in O(lg) time, implements the insertion operation
    D. The HEAP-INCREASE-KEY procedure runs in O(n lg n) time, to set the key of new node of its correct value

    1. AA, B only
    2. BA, C only
    3. CB, D only
    4. DA, B, C, D

    Answer: (B) A, C only

    Explanation

    Sign in to read the full explanation
  63. Assertion (A): The AVL trees are more balanced as compared to Red-Black trees, but they may cause more rotations during insertion and deletion.
    Reason (R): A Red-Black tree with n nodes has height that is greater than 2 log₂(n+1), and the AVL tree with n nodes has height less than log_Φ(√5(n+2)) − 2, where Φ is the golden ratio.

    1. ABoth A and R are correct and R is the correct explanation of A
    2. BBoth A and R are correct and R is NOT the correct explanation of A
    3. CA is true but R is false
    4. DA is false but R is true

    Answer: (C) A is true but R is false

    Explanation

    Sign in to read the full explanation
  64. Assertion (A): It is possible to create doubly linked list using only one pointer with every node.
    Reason (R): By storing the XOR of the addresses of the previous and next nodes.

    1. ABoth A and R are true and R is the correct explanation of A
    2. BBoth A and R are true but R is NOT the correct explanation of A
    3. CA is true but R is false
    4. DA is false but R is true

    Answer: (A) Both A and R are true and R is the correct explanation of A

    Explanation

    Sign in to read the full explanation
  65. Consider a hash table of size seven with starting index zero and a hash function h(x) = (6x + 3) mod 4. Assuming the hash table is initially empty, which of the following is the content of the table when the sequence 1, 3, 8, 10, 5 is inserted into the table using closed hashing (linear probing)? "_" denotes an empty location.

    1. A1, 3, 8, 10, 5, _, _
    2. B3, 8, 1, _, 10, 5
    3. C_, 3, 8, 1, _, 10, 5
    4. D_, 1, 3, 8, 10, 5, _

    Answer: (D) _, 1, 3, 8, 10, 5, _

    Explanation

    Sign in to read the full explanation
  66. Suppose a circular queue of capacity (n - 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables respectively. Initially, REAR = FRONT = 0. The conditions to detect queue empty and queue full are

    1. AEMPTY : REAR == FRONT ; FULL : (REAR + 1) mod n == FRONT
    2. BEMPTY : (FRONT + 1) mod n == REAR ; FULL : (REAR + 1) mod n == FRONT
    3. CEMPTY : (REAR + 1) mod n == FRONT ; FULL : REAR == FRONT
    4. DEMPTY : REAR == FRONT ; FULL : (FRONT + 1) mod n == REAR

    Answer: (A) EMPTY : REAR == FRONT ; FULL : (REAR + 1) mod n == FRONT

    Explanation

    Sign in to read the full explanation
  67. Let f(n) and g(n) be asymptotically positive functions.

    Statement I: f(n) = O(g(n)) ⇒ g(n) = Ω(f(n))
    Statement II: f(n) = O(g(n)) ⇒ lg(f(n)) = O(lg(g(n))), where lg(g(n)) ≥ 1 and f(n) ≥ 1 for all sufficiently large n.

    1. ABoth Statement I and Statement II are correct
    2. BBoth Statement I and Statement II are incorrect
    3. CStatement I is correct but Statement II is incorrect
    4. DStatement I is incorrect but Statement II is correct

    Answer: (A) Both Statement I and Statement II are correct

    Explanation

    Sign in to read the full explanation
  68. A B-tree used as an index for a large database table has four levels including the root node. If a new key is inserted into this index, what is the maximum number of nodes that could be newly created in the process?

    1. A5
    2. B4
    3. C3
    4. D2

    Answer: (A) 5

    Explanation

    Sign in to read the full explanation
  69. Let 'n' denote a positive integer. Suppose a function F is defined as

    f(n) = 0, n = 1
    f(n) = f(⌊n/2⌋) + 1, n > 1

    What is f(25)? and what does this function find?

    1. A4, ⌊log₂ n⌋
    2. B14, ⌊log₂ n⌋
    3. C4, ⌊n/2⌋
    4. D14, ⌊n/2⌋

    Answer: (A) 4, ⌊log₂ n⌋

    Explanation

    Sign in to read the full explanation
  70. Given the FFT we can have __________ time procedure for multiplying two polynomials A(x) and B(x) of degree bound n where input and output representations are in coefficient form, assuming n is a power of 2.

    1. AO(n²)
    2. BO(n log₂ n)
    3. CO(2ⁿ)
    4. DO(log₂ n)

    Answer: (B) O(n log₂ n)

    Explanation

    Sign in to read the full explanation
  71. Given an expression (A+B*D)/(E-F)+G

    A. The prefix notation is : +/+A*DB-EFG
    B. The prefix expression is the reverse of the postfix expression
    C. The order of operands in infix expression and postfix expression are the same.
    D. The order of operands in infix expression, prefix expression and postfix expression are the same.

    Choose the most appropriate answer from the options given below:

    1. AA, C and D Only
    2. BC and D Only
    3. CA and B Only
    4. DA and D Only

    Answer: (B) C and D Only

    Explanation

    Sign in to read the full explanation
  72. Match List I with List II.

    List-IList-II
    A. Dijkstra's AlgorithmI. Calculates path matrix
    B. Prim's AlgorithmII. Stores minimum cost edge
    C. Warshall's AlgorithmIII. Stores the total cost from a source node to the current node
    D. Kruskal's algorithmIV. Finds Minimum Spanning Tree

    List I and List II for the matching question

    1. AA-I, B-II, C-III, D-IV
    2. BA-III, B-II, C-I, D-IV
    3. CA-II, B-I, C-IV, D-III
    4. DA-III, B-IV, C-II, D-I

    Answer: (B) A-III, B-II, C-I, D-IV

    Explanation

    Sign in to read the full explanation
  73. In a ____ the left and right subtrees for any given node, differ in height by more than one.

    1. ABalanced Binary Tree
    2. BWeight balanced binary tree
    3. CHeight balanced tree
    4. DBinary Search Tree

    Answer: (C) Height balanced tree

    Explanation

    Sign in to read the full explanation
  74. Given six weights 4,15,25,5,8,16 construct a 2-T tree. What is the minimum weighted path length?

    1. A231
    2. B172
    3. C73
    4. D77

    Answer: (B) 172

    Explanation

    Sign in to read the full explanation
  75. Suppose we store n keys in a hash table of size m=n² using a hash function h randomly chosen from a universal class of hash functions. Then the probability is _____ that there are any collisions.

    1. Agreater than 1/5
    2. Bgreater than 1/2
    3. Cless than 1/2
    4. Dless than 1/5

    Answer: (C) less than 1/2

    Explanation

    Sign in to read the full explanation
  76. 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 sub-tree of the left sub-tree of the critical node.
    B. RR rotation: The new node is inserted in the right sub-tree of the right sub-tree of the critical node.
    C. LR rotation: The new node is inserted in the right sub-tree of the left sub-tree of the critical node.
    D. RL rotation: The new node is inserted in the left sub-tree of the right sub-tree of the critical node

    Choose the correct answer from the options given below:

    1. AA, D only
    2. BA, C Only
    3. CA, B Only
    4. DB, C Only

    Answer: (C) A, B Only

    Explanation

    Sign in to read the full explanation
  77. In the context of a Hamiltonian problem, which of the following are correct?

    A. 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. Hamiltonian path problem cannot be solved in polynomial time on directed acyclic graph
    D. If G is a connected undirected graph with at least three vertices and G³ is the graph obtained by connecting all pairs of vertices that are connected by a path in G of length at most 3.
    E. If any NP complete problem is polynomial time solvable the P=NP.

    Choose the most appropriate answer from the options given below:

    1. AA, B, C only
    2. BB, D, E only
    3. CA, D, E only
    4. DA, C, E only

    Answer: (C) A, D, E only

    Explanation

    Sign in to read the full explanation
  78. Practise Data Structures and Algorithms in a timed set
  79. For matrix multiplication, if we use divide and conquer algorithm, then ______

    A. the running time is T(n)=Θ(n³)
    B. the running time is T(n)= Θ(n² log n)
    C. The recurrence can be defined as T(n)=8T(n/2)+Θ(n²)
    D. the recurrence relation is T(n)= 8T(2n)+Θ(n²log n)
    E. Masters theorem, one of the cases is applicable

    Choose the most appropriate answer from the options given below:

    1. AA, C, E only
    2. BA, D, E only
    3. CB, D, E only
    4. DB, C, D only

    Answer: (A) A, C, E only

    Explanation

    Sign in to read the full explanation
  80. 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. AA-IV; B-III; C-I; D-II
    2. BA-III; B-IV; C-II; D-I
    3. CA-II; B-IV; C-I; D-III
    4. DA-III; B-IV; C-I; D-II

    Answer: (B) A-III; B-IV; C-II; D-I

    Explanation

    Sign in to read the full explanation
  81. 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. AA-I, B-II, C-III, D-IV
    2. BA-I, B-IV, C-II, D-III
    3. CA-IV, B-I, C-II, D-III
    4. DA-II, B-III, C-IV, D-I

    Answer: (C) A-IV, B-I, C-II, D-III

    Explanation

    Sign in to read the full explanation
  82. 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. AA, B, D, C
    2. BB, D, A, C
    3. CB, D, C, A
    4. DB, A, D, C

    Answer: (B) B, D, A, C

    Explanation

    Sign in to read the full explanation
  83. Find the optimal solution for the fractional knapsack problem when its maximum capacity is 15.

    For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

    P = {9, 5, 2, 7, 6, 16, 9}
    W = {2, 5, 6, 11, 1, 9, 3}

    1. A43
    2. B40
    3. C45
    4. D44

    Answer: (B) 40

    Explanation

    Sign in to read the full explanation
  84. What is the maximum value of items you can carry if the maximum weight allowed is 25 with a fractional knapsack?

    For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

    P = {9, 5, 2, 7, 6, 16, 9}
    W = {2, 5, 6, 11, 1, 9, 3}

    1. A48.1
    2. B49
    3. C47.9
    4. D40

    Answer: (A) 48.1

    Explanation

    Sign in to read the full explanation
  85. If a new item (P=5, W=2) is added to the list, making the total items 8 and the capacity 25, then the best-case time of the fractional knapsack for this case is __________.

    For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

    P = {9, 5, 2, 7, 6, 16, 9}
    W = {2, 5, 6, 11, 1, 9, 3}

    1. AO(8)
    2. BO(64)
    3. CO(24)
    4. DO(56)

    Answer: (C) O(24)

    Explanation

    Sign in to read the full explanation
  86. The most efficient solution for the fractional knapsack problem with maximum capacity 15 can be obtained by using________.

    For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

    P = {9, 5, 2, 7, 6, 16, 9}
    W = {2, 5, 6, 11, 1, 9, 3}

    1. ADivide and Conquer
    2. BDynamic Programming
    3. CGreedy Algorithm
    4. DBacktracking

    Answer: (C) Greedy Algorithm

    Explanation

    Sign in to read the full explanation
  87. Which of the following statements is correct for a knapsack?

    For a knapsack problem, P and W are profits and weights for a set of 7 items as given below:

    P = {9, 5, 2, 7, 6, 16, 9}
    W = {2, 5, 6, 11, 1, 9, 3}

    1. A0/1 knapsack can be applied for all kinds of problems but fractional knapsack can be applied only if the problem meets certain conditions.
    2. BThere is no difference between the two. They give the same solution for any problem.
    3. CWe use greedy algorithm for 0/1 knapsack and dynamic programming for fractional knapsack.
    4. DIn 0/1 knapsack problem, items cannot be divided into smaller portions and in fractional knapsack we can divide the item into required proportions of weight.

    Answer: (D) In 0/1 knapsack problem, items cannot be divided into smaller portions and in fractional knapsack we can divide the item into required proportions of weight.

    Explanation

    Sign in to read the full explanation
  88. Assume that f(n) and g(n) are asymptotically positive. Which of the following is correct?

    1. Af(n)=O(g(n)) and g(n)=O(h(n)) ⇒ f(n)=ω(h(n))
    2. Bf(n)=Ω(g(n)) and g(n)=Ω(h(n)) ⇒ f(n)=O(h(n))
    3. Cf(n)=o(g(n)) and g(n)=o(h(n)) ⇒ f(n)=o(h(n))
    4. Df(n)=ω(g(n)) and g(n)=ω(h(n)) ⇒ f(n)=Ω(h(n))

    Answer: (C) f(n)=o(g(n)) and g(n)=o(h(n)) ⇒ f(n)=o(h(n))

    Explanation

    Sign in to read the full explanation
  89. The solution of the recurrence relation T(n) = 3T(n/4) + n lg n is

    1. Aθ(n² lg n)
    2. Bθ(n lg n)
    3. Cθ(n lg n)²
    4. Dθ(n lg lg n)

    Answer: (B) θ(n lg n)

    Explanation

    Sign in to read the full explanation
  90. The number of nodes of height h in any n-element heap is atmost:

    1. An / 2^(h+1)
    2. Bn / 2^(h−1)
    3. Cn / 2^h
    4. D(n−1) / 2^(h−1)

    Answer: (A) n / 2^(h+1)

    Explanation

    Sign in to read the full explanation
  91. Consider a B-tree of height h, minimum degree t ≥ 2 that contains any n-key, where n ≥ 1. Which of the following is correct?

    1. Ah ≥ log ((n+1)/2) ₜ
    2. Bh ≤ log ((n+1)/2) ₜ
    3. Ch ≥ log ((n−1)/2) ₜ
    4. Dh ≤ log ((n−1)/2) ₜ

    Answer: (B) h ≤ log ((n+1)/2) ₜ

    Explanation

    Sign in to read the full explanation
  92. Which of the following algorithm design approach is used in Quick sort algorithm?

    1. ADynamic programming
    2. BBack Tracking
    3. CDivide and conquer
    4. DGreedy approach

    Answer: (C) Divide and conquer

    Explanation

    Sign in to read the full explanation
  93. Consider the hash table of size 11 that uses open addressing with linear probing. Let h(k)=k mod 11 be the hash function. A sequence of records with keys 43, 36, 92, 87, 11, 47, 11, 13, 14 is inserted into an initially empty hash table, the bins of which are indexed from 0 to 10. What is the index of the bin into which the last record is inserted?

    1. A8
    2. B7
    3. C10
    4. D4

    Answer: (B) 7

    Explanation

    Sign in to read the full explanation
  94. Consider the traversal of a tree
    Preorder → ABCEIFJDGHKL
    Inorder → EICFJBGDKHLA
    Which of the following is correct post order traversal?

    1. AEIFJCKGLHDBA
    2. BFCGKLHDBUAE
    3. CFCGKLHDBAEIJ
    4. DIEJFCGKLHDBA

    Answer: (D) IEJFCGKLHDBA

    Explanation

    Sign in to read the full explanation
  95. How many rotations are required during the construction of an AVL tree if the following elements are to be added in the given sequence?
    35, 50, 40, 25, 30, 60, 78, 20, 28

    1. A2 left rotations, 2 right rotations
    2. B2 left rotations, 3 right rotations
    3. C3 left rotations, 2 right rotations
    4. D3 left rotations, 1 right rotation

    Answer: (C) 3 left rotations, 2 right rotations

    Explanation

    Sign in to read the full explanation
  96. Consider the following graph.
    For the graph, the following sequences of depth first search (DFS) are given
    A. abcghf
    B. abfchg
    C. abfhgc
    D. afghbc
    Which of the following is correct?

    Undirected graph with vertices a, b, c, f, g, h for the DFS traversal question

    Undirected graph with vertices a, b, c, f, g, h for the DFS traversal question

    1. A(A), (B) and (D) only
    2. B(A), (B), (C) and (D)
    3. C(B), (C) and (D) only
    4. D(A), (C) and (D) only

    Answer: (D) (A), (C) and (D) only

    Explanation

    Sign in to read the full explanation
  97. Match each algorithm with its running-time complexity.

    AlgorithmComplexity
    A. Breadth First SearchII. O(V+E)
    B. Rabin-Karp AlgorithmIII. θ((n−m+1)m)
    C. Depth-First SearchI. θ(V+E)
    D. Heap sort (worst case)V. O(n lg n)
    E. Quick sort (worst case)IV. O(n²)
    1. A(A)-(III), (B)-(II), (C)-(I), (D)-(IV), (E)-(V)
    2. B(A)-(II), (B)-(III), (C)-(I), (D)-(IV), (E)-(V)
    3. C(A)-(II), (B)-(III), (C)-(I), (D)-(V), (E)-(IV)
    4. D(A)-(III), (B)-(I), (C)-(II), (D)-(IV), (E)-(V)

    Answer: (C) (A)-(II), (B)-(III), (C)-(I), (D)-(V), (E)-(IV)

    Explanation

    Sign in to read the full explanation
  98. Consider the following statements of approximation algorithm:
    Statement I: Vertex-cover is a polynomial time 2-approximation algorithm.
    Statement II: TSP-tour is a polynomial time 3-approximation algorithm for travelling salesman problem with the triangle inequality.
    Which of the following is correct?

    1. AStatement I true and Statement II false
    2. BStatement I and Statement II true
    3. CStatement I false and Statement II true
    4. DStatement I and Statement II false

    Answer: (A) Statement I true and Statement II false

    Explanation

    Sign in to read the full explanation
  99. The postfix form of the infix expression ( A + B ) * ( C * D - E ) * F / G is:

    1. AAB + CD*E - FG / **
    2. BAB + CD*E - F**G /
    3. CAB + CD*E - FG /
    4. DAB + CDE*- FG /

    Answer: (C) AB + CD*E - FG /

    Explanation

    Sign in to read the full explanation
  100. A double-ended queue is to be implemented using only stacks (push and pop). What is the time complexity of AddFront() and AddRear(), where m is the stack size and n is the number of elements?

    1. AO(m) and O(n)
    2. BO(1) and O(n)
    3. CO(n) and O(1)
    4. DO(n) and O(m)

    Answer: (B) O(1) and O(n)

    Explanation

    Sign in to read the full explanation
  101. Two balanced binary search trees hold m and n elements respectively. They can be merged into one balanced binary search tree in ______ time.

    1. AO(m*n)
    2. BO(m + n)
    3. CO(m*log n)
    4. DO(m*log(m + n))

    Answer: (B) O(m + n)

    Explanation

    Sign in to read the full explanation
  102. A data structure must store a set of integers so that each of the following runs in O(log n) time: delete the smallest element, and insert an element only if it is not already present. Which structure can be used?

    1. AA heap can be used but not a balanced binary search tree
    2. BA balanced binary search tree can be used but not a heap
    3. CBoth a balanced binary search tree and a heap can be used
    4. DNeither a balanced binary search tree nor a heap can be used

    Answer: (B) A balanced binary search tree can be used but not a heap

    Explanation

    Sign in to read the full explanation
  103. Consider the graph shown. Which of the following vertex sequences are valid depth-first traversals of this graph?

    I. a b e g h f
    II. a b f e h g
    III. a b f h g e
    IV. a f g h b e

    An undirected graph on vertices a, b, e, f, g and h.

    An undirected graph on vertices a, b, e, f, g and h.

    1. AI, II, and IV only
    2. BI and IV only
    3. CII, III, and IV only
    4. DI, III, and IV only

    Answer: (D) I, III, and IV only

    Explanation

    Sign in to read the full explanation
  104. Practise Data Structures and Algorithms in a timed set
  105. Give the increasing order of asymptotic growth of the functions f1, f2, f3, f4:

    A. f1(n) = 2^n
    B. f2(n) = n^(3/2)
    C. f3(n) = n log n
    D. f4(n) = n^(log n)

    Choose the correct answer from the options given below:

    1. AC, B, D, A
    2. BC, B, A, D
    3. CB, C, A, D
    4. DB, C, D, A

    Answer: (A) C, B, D, A

    Explanation

    Sign in to read the full explanation
  106. A hash function h(key) = key mod 7 with linear probing is used to insert the keys 44, 45, 79, 55, 91, 18, 63 into a table indexed 0 to 6. What is the final location of key 18?

    1. A3
    2. B4
    3. C5
    4. D6

    Answer: (C) 5

    Explanation

    Sign in to read the full explanation
  107. Match List-I (Standard graph algorithm) with List-II (Time complexity), where n and m are the numbers of vertices and edges.

    List-IList-II
    A. Bellman-Ford algorithmI. O(m log n)
    B. Kruskal algorithmII. O(n^3)
    C. Floyd-Warshall algorithmIII. O(n*m)
    D. Topological sortingIV. O(n + m)
    1. AA-III, B-I, C-II, D-IV
    2. BA-II, B-IV, C-III, D-I
    3. CA-III, B-IV, C-I, D-II
    4. DA-II, B-I, C-III, D-IV

    Answer: (A) A-III, B-I, C-II, D-IV

    Explanation

    Sign in to read the full explanation
  108. The reverse Polish (postfix) notation of the infix expression [A * {B + C * (D + E)}] / {F * (G + H)} is:

    1. AABCDE+*+FGH+/
    2. BABCDE*++FGH+/
    3. CABCDE+*+FGH+/
    4. DABCDE+**+FGH+*/

    Answer: (A) ABCDE+*+FGH+/

    Explanation

    Sign in to read the full explanation
  109. Consider the pseudocode with integers a and b, where a > 1 and a < b:

    int x = 0; int p = 1;
    while (p < b) { p = p * a; x = x + 1; }

    When the loop terminates, what is x in terms of a and b?

    1. A⌊logₐ b⌋
    2. B⌈logₐ b⌉
    3. Clogₐ b
    4. Daᵇ

    Answer: (B) ⌈logₐ b⌉

    Explanation

    Sign in to read the full explanation
  110. A complete n-ary tree has either n children or no children at each node. If it has I = 10 internal nodes and L = 41 leaves, what is n?

    1. A3
    2. B4
    3. C5
    4. D6

    Answer: (C) 5

    Explanation

    Sign in to read the full explanation
  111. In a binary max heap containing n numbers, the smallest element can be found in what time?

    1. AO(n)
    2. BO(log₂ n)
    3. CO(1)
    4. DO(log log n)

    Answer: (A) O(n)

    Explanation

    Sign in to read the full explanation
  112. Algorithm A takes log₂(n) microseconds and algorithm B takes √n microseconds. What are the largest problem sizes they can solve in one second?

    1. A2²⁰ and 10⁸
    2. B2¹⁰⁰⁰⁰⁰⁰ and 10¹²
    3. C2²⁰ and 6 × 10⁹
    4. D2¹⁰⁰⁰⁰⁰⁰ and 6 × 10¹¹

    Answer: (B) 2¹⁰⁰⁰⁰⁰⁰ and 10¹²

    Explanation

    Sign in to read the full explanation
  113. Let G be a directed graph on vertices 1 through 100. There is an edge i → j exactly when j = i + 1 or j = 3i. What is the minimum number of edges in a path from 1 to 100?

    1. A23
    2. B99
    3. C4
    4. D7

    Answer: (D) 7

    Explanation

    Sign in to read the full explanation
  114. The running time of an algorithm is O(g(n)) if and only if

    1. Aits worst-case running time is O(g(n)) and its best-case running time is Ω(g(n)).
    2. Bits worst-case running time is Ω(g(n)) and its best-case running time is O(g(n)).
    3. CO(g(n)) = Ω(g(n)).
    4. DO(g(n)) ∩ ω(g(n)) is non-empty.

    Answer: (A) its worst-case running time is O(g(n)) and its best-case running time is Ω(g(n)).

    Explanation

    Sign in to read the full explanation
  115. Which statements are incorrect?
    A. Every tree is 2-colourable.
    B. A bipartite graph has no even-length cycles.
    C. A graph is 2-colourable if it is bipartite.
    D. A graph of maximum degree d can be coloured with d + 1 colours.
    E. A graph with O(|V|) edges can be coloured with O(log |V|) colours.

    1. A(C) and (E)
    2. B(B) and (C)
    3. C(B) and (E)
    4. D(A) and (D)

    Answer: (C) (B) and (E)

    Explanation

    Sign in to read the full explanation
  116. Match List I with List IT
    A. B. C. D. List I
    Topological sort of DAG
    Kruskal's MST algorithm
    Bellman-Ford's single-source shortest
    path algorithm
    Floyd-Warshall's all-pair shortest
    path algorithm

    List II
    @M owv+e)
    (d) O(VvE)
    dl) av +B)

    av) av?)

    List IList II
    Items are listed in the question stem.Match each item to its stated description or complexity.
    1. AOCR review required
    2. BOCR review required
    3. COCR review required
    4. DALI, B-III, C-IV, D-II
      ALI, B-I, C-IV, D-II
      A-IT, B-I, C-II, D-IV
      A-I, B-III, C-II, D-IV

    Answer: (A) OCR review required

    Explanation

    Sign in to read the full explanation
  117. Find the lexicographic ordering of the bit strings given below based on the ordering 0 < 1.
    A. 001
    B. 010
    (Cc) O11
    D. 0001
    E. 0101

    1. A001 < 010 < 011 < 0001 < 0101 (2) 0001 <001 < 010 < 0101 < 011
    2. BOCR review required
    3. C0001 < 0101 < 001 < 010 < 011 (4) 001 < 010 < 0001 < 0101 < 011
    4. DOCR review required

    Answer: (B) OCR review required

    Explanation

    Sign in to read the full explanation
  118. Consider the undirected graph below:

    Using Prim's algorithm to construct a minimum spanning tree starting with node a. which
    one of the following sequences of edges represents a possible order in which the edges would
    be added to construct the minimum spanning tree?

    () (a.b). (a.h). (g.h). (fg). (c.f). (c.i), (¢.d). (de)

    1. AOCR review required
    2. B(a.b, (bh). (g-h). (g.i). (c.i). (c.f). (c.d), (d.e)
    3. C(a,b). (b.c). (c.i). (c.f). (fg). (gh). (c.d). (d.e)
    4. D(a.b). (g.h). (g.f). (c.f). (c.i). (fe). (b.0). (de)

    Answer: (A) OCR review required

    Explanation

    Sign in to read the full explanation
  119. Let G be a simple undirected graph, Tp be a DFS tree on G. and T, be the BFS tree on G,
    Consider the following statements.

    Statement I: No edge of Gis a cross with respect to Tp

    Statement II: For every edge (u,v) of G. if u is at depth i and v is at depth jin T; then
    li-—jl=1.

    In the light of the above statements, choose the correct answer from the options given below

    1. ABoth Statement I and Statement II are true
    2. BBoth Statement I and Statement II are false
    3. CStatement I is correct but Statement II is false
    4. DStatement I is incorrect but Statement II is true.

    Answer: (C) Statement I is correct but Statement II is false

    Explanation

    Sign in to read the full explanation
  120. Consider the following statements:

    A. The running time of dynamic programming algorithm is alway θ(p) where p is number of subproblems.
    B. When a recurrence relation has cyclic dependency, it is impossible to use that recurrence relation (unmodified) in a correct dynamic program.
    C. For a dynamic programming algorithm, computing all values in a bottom-up fashion is asymptotically faster than using recursion and memorization.
    D. If a problem X can be reduced to a known NP-hard problem, then X must be NP-hard.

    Which of the statement(s) is (are) true?

    1. AOnly B and A
    2. BOnly B
    3. COnly B and C
    4. DOnly B and D

    Answer: (B) Only B

    Explanation

    Sign in to read the full explanation
  121. When using Dijkstra’s algorithm to find shortest path in a graph, which of the following statement is not true?

    1. AIt can find shortest path within the same graph data structure
    2. BEvery time a new node is visited, we choose the node with smallest known distance/cost (weight) to visit first
    3. CShortest path always passes through least number of vertices
    4. DThe graph needs to have a non-negative weight on every edge

    Answer: (C) Shortest path always passes through least number of vertices

    Explanation

    Sign in to read the full explanation
  122. Give asymptotic upper and lower bound for T(n) given below. Assume T(n) is constant for n ≤ 2.

    T(n) = 4T(√n) + lg²n

    1. AT(n) = θ(lg(lg²n) lg n)
    2. BT(n) = θ(lg²n lg n)
    3. CT(n) = θ(lg²n lg lg n)
    4. DT(n) = θ(lg(lg n) lg n)

    Answer: (C) T(n) = θ(lg²n lg lg n)

    Explanation

    Sign in to read the full explanation
  123. The time complexity to multiply two polynomials of degree n using Fast Fourier transform method is:

    1. Aθ(n lg n)
    2. Bθ(n²)
    3. Cθ(n)
    4. Dθ(lg n)

    Answer: (A) θ(n lg n)

    Explanation

    Sign in to read the full explanation
  124. In a B-Tree, each node represents a disk block. Suppose one block holds 8192 bytes. Each key uses 32 bytes. In a B-tree of order M there are M - 1 keys. Since each branch is on another disk block, we assume a branch is of 4 bytes. The total memory requirement for a non-leaf node is:

    1. A32M - 32
    2. B36M - 32
    3. C36M - 36
    4. D32M - 36

    Answer: (B) 36M - 32

    Explanation

    Sign in to read the full explanation
  125. What is the worst case running time of Insert and Extract-min, in an implementation of a priority queue using an unsorted array? Assume that all insertions can be accommodated.

    1. Aθ(1), θ(n)
    2. Bθ(n), θ(1)
    3. Cθ(1), θ(1)
    4. Dθ(n), θ(n)

    Answer: (A) θ(1), θ(n)

    Explanation

    Sign in to read the full explanation
  126. The following multithreaded algorithm computes transpose of a matrix in parallel:

    p Trans (X, Y, N)
    if N = 1
     then Y[1,1] ← X[1,1]
    else partition X into four (N/2) × (N/2) submatrices X₁₁, X₁₂, X₂₁, X₂₂
     partition Y into four (N/2) × (N/2) submatrices Y₁₁, Y₁₂, Y₂₁, Y₂₂
     spawn p Trans (X₁₁, Y₁₁, N/2)
     spawn p Trans (X₁₂, Y₂₁, N/2)
     spawn p Trans (X₂₁, Y₁₂, N/2)
     spawn p Trans (X₂₂, Y₂₂, N/2)
    

    What is the asymptotic parallelism of the algorithm?

    1. AT₁/T∞ or θ(N²/lg N)
    2. BT₁/T∞ or θ(N/lg N)
    3. CT₁/T∞ or θ(lg N/N²)
    4. DT₁/T∞ or θ(lg N/N)

    Answer: (A) T₁/T∞ or θ(N²/lg N)

    Explanation

    Sign in to read the full explanation
  127. Consider a weighted directed graph. The current shortest distance from source S to node x is represented by d[x]. Let d[v] = 29, d[u] = 15, w[u,v] = 12. What is the updated value of d[v] based on current information?

    1. A29
    2. B27
    3. C25
    4. D17

    Answer: (B) 27

    Explanation

    Sign in to read the full explanation
  128. The weight of minimum spanning tree in graph G, calculated using Kruskal’s algorithm is:

    Graph G for Kruskal minimum spanning tree algorithm

    Graph G for Kruskal minimum spanning tree algorithm

    1. A14
    2. B15
    3. C17
    4. D18

    Answer: (B) 15

    Explanation

    Sign in to read the full explanation
  129. A clique in an undirected graph G = (V,E) is a subset V' ⊆ V of vertices, such that:

    1. AIf (u, v) ∈ E then u ∈ V' and v ∈ V'
    2. BIf (u, v) ∈ E then u ∈ V' or v ∈ V'
    3. CEach pair of vertices in V' is connected by an edge
    4. DAll pairs of vertices in V' are not connected by an edge

    Answer: (C) Each pair of vertices in V' is connected by an edge

    Explanation

    Sign in to read the full explanation
  130. Practise Data Structures and Algorithms in a timed set
  131. Question 126

    UGC NET June 2019

    Which of the following is application of depth-first search?

    1. AOnly topological sort
    2. BOnly strongly connected components
    3. CBoth topological sort and strongly connected components
    4. DNeither topological sort nor strongly connected components

    Answer: (C) Both topological sort and strongly connected components

    Explanation

    Sign in to read the full explanation
  132. Question 127

    UGC NET June 2019

    Consider the following steps:
    S₁: Characterize the structure of an optimal solution
    S₂: Compute the value of an optimal solution in bottom-up fashion

    Which of the step(s) is/are common to both dynamic programming and greedy algorithms?

    1. AOnly S₁
    2. BOnly S₂
    3. CBoth S₁ and S₂
    4. DNeither S₁ nor S₂

    Answer: (A) Only S₁

    Explanation

    Sign in to read the full explanation
  133. Question 128

    UGC NET June 2019

    There are many sorting algorithms based on comparison. The running time of heapsort algorithm is O(n lg n). Like P, but unlike Q, heapsort sorts in place where (P, Q) is equal to

    1. AMerge sort, Quick sort
    2. BQuick sort, insertion sort
    3. CInsertion sort, Quick sort
    4. DInsertion sort, Merge sort

    Answer: (D) Insertion sort, Merge sort

    Explanation

    Sign in to read the full explanation
  134. Question 129

    UGC NET June 2019

    Consider the following properties with respect to a flow network G = (V, E), in which a flow is a real-valued function f : V × V → R:
    P₁: For all u, v ∈ V, f(u, v) = -f(v, u)
    P₂: ∑ᵤ ∈ V f(u, v) = 0 for all u ∈ V

    Which one of the following is/are correct?

    1. AOnly P₁
    2. BOnly P₂
    3. CBoth P₁ and P₂
    4. DNeither P₁ nor P₂

    Answer: (A) Only P₁

    Explanation

    Sign in to read the full explanation
  135. Question 130

    UGC NET June 2019

    Which of the following is best running time to sort n integers in the range 0 to n² - 1?

    1. AO(lg n)
    2. BO(n)
    3. CO(n lg n)
    4. DO(n²)

    Answer: (B) O(n)

    Explanation

    Sign in to read the full explanation
  136. Question 131

    UGC NET June 2019

    Consider the following pseudo-code fragment in which an invariant for the loop is "m*x^k = p^n and k ≥ 0" (here, p and n are integer variables that have been initialized):

    /* Pre-conditions: p ≥ 1 ∧ n ≥ 0 */
    /* Assume that overflow never occurs */
    int x = p; int k = n; int m = 1;
    while (k <> 0) {
      if (k is odd) then m = m*x;
      x = x*x;
      k = [k/2]; /* floor(k/2) */
    }
    

    Which of the following must be true at the end of the while loop?

    1. Ax = p^n
    2. Bm = p^n
    3. Cp = x^n
    4. Dp = m^n

    Answer: (B) m = p^n

    Explanation

    Sign in to read the full explanation
  137. Question 132

    UGC NET June 2019

    Match List-I with List-II:

    List-IList-II
    (a) Prim's algorithm(i) O(V³ log V)
    (b) Dijkstra's algorithm(ii) O(VE²)
    (c) Faster all-pairs shortest path(iii) O(E lg V)
    (d) Edmonds-Karp algorithm(iv) O(V²)
    1. A(a)-(ii); (b)-(iv); (c)-(i); (d)-(iii)
    2. B(a)-(iii); (b)-(iv); (c)-(i); (d)-(ii)
    3. C(a)-(ii); (b)-(i); (c)-(iv); (d)-(iii)
    4. D(a)-(iii); (b)-(i); (c)-(iv); (d)-(ii)

    Answer: (B) (a)-(iii); (b)-(iv); (c)-(i); (d)-(ii)

    Explanation

    Sign in to read the full explanation
  138. Question 133

    UGC NET June 2019

    Consider double hashing of the form
    h(k, i) = (h₁(k) + i h₂(k)) mod m
    where h₁(k) = k mod m
    h₂(k) = 1 + (k mod n)
    where n = m - 1 and m = 701

    For k = 123456, what is the difference between first and second probes in terms of slots?

    1. A255
    2. B256
    3. C257
    4. D258

    Answer: (C) 257

    Explanation

    Sign in to read the full explanation
  139. Consider the weighted graph for Kruskal's algorithm.

    Use Kruskal’s algorithm to find the minimum spanning tree of the graph.
    The weight of this minimum spanning tree is

    Weighted undirected graph for Kruskal algorithm

    Weighted undirected graph for Kruskal algorithm

    1. A16
    2. B13
    3. C14
    4. D17

    Answer: (A) 16

    Explanation

    Sign in to read the full explanation
  140. Consider the following pseudo-code fragment, where m is a non-negative integer that has been initialized :

    p = 0;
    k = 0;
    while (k < m)
     p = p + 2^k;
     k = k + 1;
    end while
    

    Which of the following is a loop invariant for the while statement ?
    (Note : a loop invariant for a while statement is an assertion that is true each time the guard is evaluated during the execution of the while statement).

    1. Ap = 2^(k+1) – 1 and 0 ≤ k < m
    2. Bp = 2^k – 1 and 0 ≤ k < m
    3. Cp = 2^k – 1 and 0 ≤ k ≤ m
    4. Dp = 2^(k+1) – 1 and 0 ≤ k ≤ m

    Answer: (C) p = 2^k – 1 and 0 ≤ k ≤ m

    Explanation

    Sign in to read the full explanation
  141. Match List-I with List-II and choose the correct answer from the code:
    where V and E are the number of vertices and edges in graph respectively.

    List-I (Graph Algorithm)List-II (Time Complexity)
    (a) Dijkstra’s algorithm(i) O(E lg E)
    (b) Kruskal’s algorithm(ii) Θ(V³)
    (c) Floyd-Warshall algorithm(iii) O(V²)
    (d) Topological sorting(iv) Θ(V + E)

    Graph algorithms and their time complexities

    1. A(iii) (i) (iv) (ii)
    2. B(i) (iii) (iv) (ii)
    3. C(i) (iii) (ii) (iv)
    4. D(iii) (i) (ii) (iv)

    Answer: (D) (iii) (i) (ii) (iv)

    Explanation

    Sign in to read the full explanation
  142. Consider the following postfix expression with single digit operands :

    6 2 3 * / 4 2 * + 6 8 * –

    The top two elements of the stack after the second * is evaluated, are :

    1. A8, 2
    2. B8, 1
    3. C6, 2
    4. D6, 3

    Answer: (B) 8, 1

    Explanation

    Sign in to read the full explanation
  143. Consider two sequences X and Y :

    X = <0, 1, 2, 1, 3, 0, 1>
    Y = <1, 3, 2, 0, 1, 0>

    The length of longest common subsequence between X and Y is

    1. A2
    2. B3
    3. C5
    4. D4

    Answer: (D) 4

    Explanation

    Sign in to read the full explanation
  144. The solution of recurrence relation :

    T(n) = 2T (√n) + lg (n)

    is :

    1. AO(lg (n) lg(lg (n)))
    2. BO(n lg (n))
    3. CO(lg (n))
    4. DO(lg (n) lg (n))

    Answer: (A) O(lg (n) lg(lg (n)))

    Explanation

    Sign in to read the full explanation
  145. The second smallest of n elements can be found with ________ comparisons in the worst case.

    1. A3n/2
    2. Bn + ceil(lg n) – 2
    3. Clg n
    4. Dn–1

    Answer: (B) n + ceil(lg n) – 2

    Explanation

    Sign in to read the full explanation
  146. The elements 42, 25, 30, 40, 22, 35, 26 are inserted one by one in the given order into a max-heap. The resultant max-heap is stored in an array implementation as

    1. A<42, 35, 40, 22, 25, 26, 30>
    2. B<42, 35, 40, 22, 25, 30, 26>
    3. C<42, 40, 35, 25, 22, 26, 30>
    4. D<42, 40, 35, 25, 22, 30, 26>

    Answer: (D) <42, 40, 35, 25, 22, 30, 26>

    Explanation

    Sign in to read the full explanation
  147. A binary search tree is constructed by inserting the following numbers in order :

    60, 25, 72, 15, 30, 68, 101, 13, 18, 47, 70, 34

    The number of nodes is the left subtree is

    1. A3
    2. B7
    3. C5
    4. D6

    Answer: (B) 7

    Explanation

    Sign in to read the full explanation
  148. Consider a singly linked list. What is the worst case time complexity of the best-known algorithm to delete the node a, pointer to this node is q, from the list ?

    1. AO(n)
    2. BO(n lg n)
    3. CO(1)
    4. DO(lg n)

    Answer: (C) O(1)

    Explanation

    Sign in to read the full explanation

Frequently asked questions

How many Data Structures and Algorithms questions have been asked in UGC NET Computer Science?

143 Data Structures and Algorithms questions appear in the UGC NET Computer Science papers held between 2018–2026, and all of them are on this page with their answer key.

Are the answers on this page free?

Yes. Every question, its options, and the correct answer are free to read with no account. Signing in additionally unlocks the detailed explanation under each question.

Is Data Structures and Algorithms an important topic for UGC NET Computer Science?

Data Structures and Algorithms appears in every recent UGC NET Computer Science paper, across all 14 sittings covered here. Its share of the paper makes it worth revising thoroughly rather than sampling.

How should I practise Data Structures and Algorithms after reading these questions?

Attempt the Data Structures and Algorithms topic-wise sets, which put the same questions into a timed interface with instant scoring and weak-area analysis afterwards.

More Computer Science PYQs by topic

More Computer Science practice

Ready for a full paper?

Attempt Paper 1 + Paper 2 (Computer Science) together in a single timed session.

Full Mock Tests →