chapter
    Data Structures PYQs for GATE DA

    GATE DA Data Structures: 3 chapters, 8 previous year questions (26% of Programming, Data Structures and Algorithms), 452 practice questions and one solved que

    A question from this chapter

    Question 1
    2025 PYQ
    Level 3: Exam Standard
    Consider the following pseudocode.

    Create empty stack S
    
    Set x=0, flag=0, sum=0
    
    Push x onto S
    
    while (S is not empty){
    
        if (flag equals 0){
    
            Set x = x+1
    
            Push x onto S}
    
        if (x equals 8):
    
        Set flag=1
    
        if (flag equals 1){
    
        x = Pop(S)
    
        if (x is odd):
    
        Pop(S)
    
        Set sum = sum + x}
    
    }
    
    Output sum

    The value of sum output by a program executing the above pseudocode is
    (Answer in integer)
    Question 2
    2025 PYQ
    Level 3: Exam Standard
    Consider a hash table of size with indices , with the hash function


    where linear probing is used to handle collisions. The hash table is initially empty and then the following sequence of keys is inserted into the hash table: . The indices where the keys and are stored are, respectively
    Question 3
    2026 PYQ
    Level 3: Exam Standard
    You are given the following Pre-order and In-order traversals of a Binary Tree T with nodes E, F, G, P, Q, R, S.
    Pre-order: P Q S E R F G
    In-order: S Q E P F R G
    Which of the following statements is/are true about the Binary Tree T?
    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Data Structures PYQs for GATE DA

    GATE DA Data Structures: 3 chapters, 8 previous year questions (26% of Programming, Data Structures and Algorithms), 452 practice questions and one solved question from each chapter.

    About Data Structures Previous Year Questions (PYQs)

    8 previous year questions from Data Structures in GATE DA, grouped by chapter with the exam year, answer key and step-by-step solution for each.

    Data Structures Weightage in GATE DA

    Data Structures accounts for 8 of 31 Programming, Data Structures and Algorithms previous year questions in our bank (26%), about 2.7 per paper across 3 papers.

    Data Structures Chapter Matrix

    ChapterTopicsPYQsShare of unit PYQsPractice questions
    Stacks, Queues and DequesStack Operations and Simulation, Queue and Deque Operations, ADT Properties: FIFO, LIFO and Lookup338%161
    Hash Tables and Collision ResolutionHash Tables with Open Addressing and Linear Probing, Uniform Hashing and Probe Complexity225%126
    Binary Trees: Properties and TraversalsBinary Tree Traversals and Reconstruction, Binary Tree Structural Properties338%165

    More from Programming, Data Structures and Algorithms

    One Solved Question from Each Data Structures Chapter

    Question 1 · Stacks, Queues and Deques · 2025 NAT
    Consider the following pseudocode.

    Create empty stack S
    
    Set x=0, flag=0, sum=0
    
    Push x onto S
    
    while (S is not empty){
    
        if (flag equals 0){
    
            Set x = x+1
    
            Push x onto S}
    
        if (x equals 8):
    
        Set flag=1
    
        if (flag equals 1){
    
        x = Pop(S)
    
        if (x is odd):
    
        Pop(S)
    
        Set sum = sum + x}
    
    }
    
    Output sum

    The value of sum output by a program executing the above pseudocode is
    (Answer in integer)
    Correct Answer:

    24

    Step-by-Step Solution

    Key idea: This is a stack simulation question, recognizable because it provides pseudocode with stack operations (Push, Pop) and conditional logic, asking for the final state of a variable.

    Step 1: Initialize variables. , , . Stack is initialized with , so .

    Step 2: Trace the loop while is not empty.

    • Iterations 1 to 7: is . increments by each time and is pushed. becomes . reaches .
    • Iteration 8: , so becomes and is pushed. . Now , so becomes . Since , we execute the pop block: . is even, so the inner pop is skipped. .
    • Iteration 9: . . is odd, so we again, removing . is now . .
    • Iteration 10: . . is odd, so we again, removing . is now . .
    • Iteration 11: . . is odd, so we again, removing . is now . .
    • Iteration 12: . . is odd, so we again, removing . is now . .

    Step 3: The stack is now empty, so the loop terminates. The final value of is .

    Answer: 24

    Question 2 · Hash Tables and Collision Resolution · 2025 MCQ
    Consider a hash table of size with indices , with the hash function


    where linear probing is used to handle collisions. The hash table is initially empty and then the following sequence of keys is inserted into the hash table: . The indices where the keys and are stored are, respectively
    1. A.

      and

    2. B.

      and

    3. C.

      and

    4. D.

      and

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: This is a hash table tracing question, recognizable because it provides a specific hash function, collision resolution strategy, and a sequence of keys to insert.

    Step 1: Understand the hash function and table size. The table has size 10 (indices 0 to 9). The hash function is .

    Step 2: Trace the insertion of each key sequentially using linear probing.

    • Insert 1: . Index 3 is empty. Place 1 at index 3.
    • Insert 4: . Index 2 is empty. Place 4 at index 2.
    • Insert 5: . Index 5 is empty. Place 5 at index 5.
    • Insert 6: . Index 8 is empty. Place 6 at index 8.
    • Insert 14: . Index 2 is occupied (by 4).
    • Probe 1: . Index 3 is occupied (by 1).
    • Probe 2: . Index 4 is empty. Place 14 at index 4.
    • Insert 15: . Index 5 is occupied (by 5).
    • Probe 1: . Index 6 is empty. Place 15 at index 6.

    Step 3: Identify the final indices. Key 14 is at index 4, and key 15 is at index 6.

    Answer: D

    Question 3 · Binary Trees: Properties and Traversals · 2026 MSQ
    You are given the following Pre-order and In-order traversals of a Binary Tree T with nodes E, F, G, P, Q, R, S.
    Pre-order: P Q S E R F G
    In-order: S Q E P F R G
    Which of the following statements is/are true about the Binary Tree T?
    1. A.

      Node P is the root of T

    2. B. The Post-order traversal of T is:
      S E Q F G R P
    3. C.

      Node Q has only one child

    4. D.

      The left subtree of node R contains the node G

    Correct Answer:

    ["A","B"]

    Step-by-Step Solution

    Insight: Reconstruct the tree using the standard Pre-order and In-order split method.

    Exam route: Root is P. Left In-order has 3 elements, Right has 3. Split Pre-order accordingly. Build left and right subtrees. Check options.

    Learning route:

    Step 1: Root is the first element in Pre-order: P.

    Step 2: Find P in In-order. Left of P is S, Q, E (size 3). Right of P is F, R, G (size 3).

    Step 3: Split remaining Pre-order (Q, S, E, R, F, G) into Left Pre-order (Q, S, E) and Right Pre-order (R, F, G).

    Step 4: Left subtree: Pre (Q, S, E), In (S, Q, E). Root is Q. Left In is S, Right In is E. So Q has left child S, right child E.

    Step 5: Right subtree: Pre (R, F, G), In (F, R, G). Root is R. Left In is F, Right In is G. So R has left child F, right child G.

    Step 6: Evaluate options.

    A) P is root. (True)

    B) Post-order is Left Post + Right Post + Root. Left Post: S, E, Q. Right Post: F, G, R. Total: S, E, Q, F, G, R, P. (True)

    C) Q has two children (S and E). (False)

    D) G is in the right subtree of R. (False)