|Data Structures and Algorithms PYQs

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

Practise 34 Data Structures and Algorithms questions asked in UGC NET Computer Science from 2020–2025. 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.

34 PYQs2020–2025Answers includedFree

Practise Data Structures and Algorithms as timed sets

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

Start practice

All 34 Data Structures and Algorithms PYQs

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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. Considering the binary tree shown, what will be the inorder traversal?

    NodeLeft childRight child
    ABC
    CDE
    EF
    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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. ___________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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. Practise Data Structures and Algorithms in a timed set
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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

Frequently asked questions

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

34 Data Structures and Algorithms questions appear in the UGC NET Computer Science papers held between 2020–2025, 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 4 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 →