GATE CSE Programming and Data Structures PYQ analysis
Topic-wise weightage of Programming and Data Structures from the 15 official GATE CSE papers on this site (2017–2026), with every question listed under the syllabus topics it tests.
10.7
average marks per paper
105
PYQs (2017–2026)
4 / 5
syllabus topics asked
#3 of 11
subjects by marks
Programming and Data Structures weightage by year
Per paper; a year with two sessions shows their average. Of the 105 questions, 52 MCQ, 10 MSQ, 43 NAT; 56 carry 2 marks.
| Measure | 20172 papers | 2018 | 2019 | 2020 | 20212 papers | 2022 | 2023 | 20242 papers | 20252 papers | 20262 papers | Average |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Marks | 12 | 12 | 12 | 13 | 7.5 | 10 | 10 | 9 | 11.5 | 12 | 10.7 |
| Questions | 7.5 | 8 | 7 | 9 | 5 | 7 | 7 | 5.5 | 7.5 | 8 | 7 |
Programming and Data Structures topic-wise weightage
Every topic of the official syllabus, most marks first. Year columns show marks per paper; marks count each question once, under its main topic, while “Questions” also counts supporting topics.
| Topic | 20172 papers | 2018 | 2019 | 2020 | 20212 papers | 2022 | 2023 | 20242 papers | 20252 papers | 20262 papers | Marks | Questions | Share |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Programming in C | 6.5 | 5 | 8 | 5 | 2.5 | 5 | 1 | 3.5 | 4.5 | 2.5 | 63 | 51 | |
| Trees, binary search trees and binary heaps | 1.5 | 3 | 2 | 6 | 1 | 1 | 5 | 3 | 2 | 4.5 | 41 | 30 | |
| Arrays, stacks, queues and linked lists | 1 | 1 | – | 1 | 1.5 | 3 | 3 | 2 | 3 | 2 | 27 | 19 | |
| Recursion | 2 | 3 | 2 | – | 1.5 | – | – | 0.5 | 1 | 2 | 19 | 14 | |
| GraphsNot asked yet | – | – | – | – | – | – | – | – | – | – | – | – |
Programming and Data Structures PYQs by topic
Newest first. A question can appear under up to three topics; one filed under another subject is marked with that subject.
Programming in C
51 questions · 63 marks as main topic · asked in 10 of 10 years · last in 2026
- 2026 Session 1 · Q34Output of a C function with a shadowed block variable1M · NAT
- 2026 Session 2 · Q17What is stored on the heap in the C runtime1M · MCQ
- 2026 Session 2 · Q19Which C programs with redeclared variable a compile1M · MCQ
- 2026 Session 2 · Q60Output of a C program reassigning through a pointer2M · NAT
- 2026 Session 2 · Q61Maximum value returned by a recursive function on length mod 3supporting · 2M · NAT
- 2025 Session 1 · Q34Output after writing through a pointer in a function1M · NAT
- 2025 Session 1 · Q63Output of gate(14362): keep alternate digits2M · NAT
- 2025 Session 2 · Q19Overlapping string copy without the terminating null1M · MCQ
- 2025 Session 2 · Q33Output of a subtraction loop on 126 and 1051M · NAT
- 2025 Session 2 · Q62Pointer arithmetic and increment through a pointer2M · NAT
- 2025 Session 2 · Q63Sum of nested function calls in a loop2M · NAT
- 2024 Session 1 · Q18Output of a C while loop with integer division1M · MCQ
- 2024 Session 1 · Q19Recursive getchar/putchar on input 1234supporting · 1M · MCQ
- 2024 Session 1 · Q48Return value bounds of a loop computing x = x + x + y2M · MSQ
- 2024 Session 2 · Q13Output when function arguments are evaluated right to left1M · MCQ
- 2024 Session 2 · Q33Behaviour of a pointer-walking string length function1M · MSQ
- 2024 Session 2 · Q36Pointer difference and value difference for a double array2M · MCQ
- 2023 · Q35Output of a C program using a static local variable1M · NAT
- 2022 · Q21Output of a C program using pointers to an int and an array1M · MCQ
- 2022 · Q43Output of printing a[i][0][k] from a 3-D array2M · MCQ
- 2022 · Q44Bitwise operations on characters P and x in C2M · MCQ
- 2021 Set 1 · Q47Output of a loop with a short-circuited post-increment2M · MCQ
- 2021 Set 1 · Q58Value returned by a Horner-style loop on an all-ones array2M · NAT
- 2021 Set 2 · Q20Output of *(arr[1] + 9) for a 4×5 int array1M · MCQ
- 2021 Set 2 · Q33Value returned by a subtraction-based recursive functionsupporting · 1M · NAT
- 2021 Set 2 · Q45Bug in a linked-list program: uninitialized next pointersupporting · 2M · MCQ
- 2020 · Q32Output of pointer arithmetic on a 2D array: *(*(a+**a+2)+3)1M · NAT
- 2020 · Q56Return value of fun2(5) with static variables in recursion2M · NAT
- 2020 · Q58Value of pp(3, 4) for binary exponentiation code2M · NAT
- 2019 · Q28C program with jumble(x, y) = 2x + y called twice: value printed1M · NAT
- 2019 · Q34Pointer ip = arr + 4: value of ip[1]1M · NAT
- 2019 · Q36Recursive convert(n) with n/2 and n%2: behaviour for positive nsupporting · 2M · MCQ
- 2019 · Q37Static counter r() used in for-loop init, condition, update and body2M · MCQ
- 2019 · Q62Number of times sum is printed in a float halving loop2M · NAT
- 2019 · Q63Output of a C pointer arithmetic loop over an array2M · NAT
- 2018 · Q12C struct accessed through a char pointer1M · MCQ
- 2018 · Q31Number of recursive calls counted in a C programsupporting · 1M · NAT
- 2018 · Q39Swapping string pointers by value and by address in C2M · MCQ
- 2018 · Q42Value returned by nested halving loops for input 2^402M · MCQ
- 2017 Session 1 · Q18C linked list join(m, n): what does it dosupporting · 1M · MCQ
- 2017 Session 1 · Q23C code with malloc and assignval: which problem occurs1M · MCQ
- 2017 Session 1 · Q45Output of mutually recursive fun1(5) and fun2 with printfsupporting · 2M · MCQ
- 2017 Session 1 · Q46foo(3) with val-- recursion and bar(3) with val-1: termination behavioursupporting · 2M · MCQ
- 2017 Session 1 · Q63printlength with unsigned strlen difference: output for "abc" and "defgh"2M · NAT
- 2017 Session 1 · Q65Output of C program summing total(i) with a static bit-count accumulator2M · NAT
- 2017 Session 2 · Q12Match C declarations with their memory meaning1M · MCQ
- 2017 Session 2 · Q24Output of printxy(1,1) with pointer to a parameter1M · MCQ
- 2017 Session 2 · Q47Precondition for division by repeated subtraction loop2M · MCQ
- 2017 Session 2 · Q53Output of a bidirectional bubble sort snippetsupporting · 2M · NAT
- 2017 Session 2 · Q64Output of pre/post increment and decrement program2M · NAT
- 2017 Session 2 · Q65strlen with pointer arithmetic and i[p] array indexing2M · NAT
Trees, binary search trees and binary heaps
30 questions · 41 marks as main topic · asked in 10 of 10 years · last in 2026
- 2026 Session 1 · Q23Non-leaf indices in a 1-indexed binary heap with n odd1M · MSQ
- 2026 Session 1 · Q33Maximum height of a full binary tree with 23 nodes1M · NAT
- 2026 Session 1 · Q40Third insertion that can never yield a complete BST of 1..152M · MCQ
- 2026 Session 1 · Q62Postorder position of 60 in a BST given by its preorder2M · NAT
- 2026 Session 2 · Q12Match binary tree traversals with visiting orders1M · MCQ
- 2026 Session 2 · Q49Inserting a key between each BST leaf and its inorder successor2M · MSQ
- 2025 Session 1 · Q26True facts about any binary search tree1M · MSQ
- 2025 Session 1 · Q35Height of a min-heap with 32 keys1M · NAT
- 2025 Session 2 · Q13Internal nodes in a full binary tree with n nodes1M · MCQ
- 2025 Session 2 · Q35Depth of node 19 in a binary search tree1M · NAT
- 2025 Session 2 · Q38Worst-case meld time for list, array heap and BSTsupporting · 2M · MCQ
- 2024 Session 1 · Q41First three elements after heapifying an array2M · MCQ
- 2024 Session 1 · Q43Possible positions of the maximum in a 105-element min-heap2M · MCQ
- 2024 Session 2 · Q39What can be known about a BST from its set of keys alone2M · MCQ
- 2023 · Q12Which array A[1..10] is a max-heap1M · MCQ
- 2023 · Q46Worst-case Extract-Max and Insert on a max-heap2M · MCQ
- 2023 · Q47Output of a recursive subtree-sum function on a binary tree2M · MCQ
- 2022 · Q28Array index of the 3rd largest element of a complete BST1M · NAT
- 2021 Set 1 · Q20Time to pick a BST element smaller than the maximum1M · MCQ
- 2021 Set 1 · Q57Insertion order producing a given dynamic hashing statesupporting · 2M · MSQ
- 2021 Set 2 · Q12Finding the maximum element in a binary min-heap1M · MCQ
- 2020 · Q15Postorder of a BST from its preorder 15, 10, 12, 11, 20, 18, 16, 191M · MCQ
- 2020 · Q16Worst-case time to insert n^2 elements into an AVL tree of n1M · MCQ
- 2020 · Q51Range reporting in a balanced BST with k results2M · MCQ
- 2020 · Q57Comparisons to find the maximum in a min-heap of 1023 elements2M · NAT
- 2019 · Q50True statements about max-heaps and binary search trees2M · MCQ
- 2018 · Q30Height of binary tree from postorder and inorder traversals1M · NAT
- 2018 · Q56Number of distinct min-heaps on the values 1 to 72M · NAT
- 2017 Session 1 · Q16Minimum and maximum height of a BST with 15 nodes1M · MCQ
- 2017 Session 2 · Q46Post-order traversal of a BST from its pre-order traversal2M · MCQ
Arrays, stacks, queues and linked lists
19 questions · 27 marks as main topic · asked in 9 of 10 years · last in 2026
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked list2M · MCQ
- 2026 Session 2 · Q50Stack/queue assignments that produce the output 4 3 1 2 52M · MSQ
- 2025 Session 1 · Q61Recursive count of runs in an arraysupporting · 2M · NAT
- 2025 Session 1 · Q62Nodes left in L1 after deleting values found in L22M · NAT
- 2025 Session 2 · Q38Worst-case meld time for list, array heap and BST2M · MCQ
- 2025 Session 2 · Q45Supporting an O(1) MIN operation on a stack2M · MSQ
- 2024 Session 2 · Q42Missing expressions in longest two-distinct-value subarray code2M · MCQ
- 2024 Session 2 · Q48Output sequences possible with two bounded stacks2M · MSQ
- 2023 · Q13Worst-case node deletion in singly vs doubly linked lists1M · MCQ
- 2023 · Q59Top of stack after mixed stack and queue operations2M · NAT
- 2022 · Q15Time to reverse a singly linked list in O(1) space1M · MCQ
- 2022 · Q43Output of printing a[i][0][k] from a 3-D arraysupporting · 2M · MCQ
- 2022 · Q62Minimum enqueues on Q1 to reverse its elements into Q22M · NAT
- 2021 Set 1 · Q31Stack pop plus queue dequeue after a sequence of operations1M · NAT
- 2021 Set 2 · Q45Bug in a linked-list program: uninitialized next pointer2M · MCQ
- 2020 · Q26Worst-case time to build a sorted linked list by n insertions1M · MCQ
- 2018 · Q13Queue on a singly linked list: enqueue at head, dequeue at tail1M · MCQ
- 2017 Session 1 · Q18C linked list join(m, n): what does it do1M · MCQ
- 2017 Session 2 · Q23Circular queue as singly linked list with FRONT and REAR pointers1M · MCQ
Recursion
14 questions · 19 marks as main topic · asked in 9 of 10 years · last in 2026
- 2026 Session 1 · Q39Recursive length of a non-empty singly linked listsupporting · 2M · MCQ
- 2026 Session 1 · Q61Smallest n for which foo(n) = 5 with foo(bar(n))2M · NAT
- 2026 Session 2 · Q61Maximum value returned by a recursive function on length mod 32M · NAT
- 2025 Session 1 · Q61Recursive count of runs in an array2M · NAT
- 2024 Session 1 · Q19Recursive getchar/putchar on input 12341M · MCQ
- 2023 · Q47Output of a recursive subtree-sum function on a binary treesupporting · 2M · MCQ
- 2021 Set 2 · Q33Value returned by a subtraction-based recursive function1M · NAT
- 2021 Set 2 · Q59Output of a doubly recursive function foo(15, 15, 10)2M · NAT
- 2020 · Q56Return value of fun2(5) with static variables in recursionsupporting · 2M · NAT
- 2019 · Q36Recursive convert(n) with n/2 and n%2: behaviour for positive n2M · MCQ
- 2018 · Q31Number of recursive calls counted in a C program1M · NAT
- 2018 · Q55Number of prints by recursive Count(1024,1024)2M · NAT
- 2017 Session 1 · Q45Output of mutually recursive fun1(5) and fun2 with printf2M · MCQ
- 2017 Session 1 · Q46foo(3) with val-- recursion and bar(3) with val-1: termination behaviour2M · MCQ