GATE CSE Programming and Data Structures (PDS) PYQs
In GATE CS, Programming in C is tested extensively through rigorous code tracing, pointer mechanics, and fundamental semantics rather than high-level syntax tri… Read the guide
- Topics
- 9
- Questions
- 163
- Marks / paper
- 9.5
- Asked
- since 2011
These are the 163 GATE CSE Programming and Data Structures PYQs (since 2011), grouped topic-wise with solutions. See all GATE CSE PYQs or GATE CSE question papers by year.
Topics
Open a topic to browse its questions, or practice it as a timed test.
By year
Jump to the first question from each year’s paper.
What GATE tests in Programming and Data Structures
Concepts, patterns, formulas and traps distilled from past papers.
In GATE CS, Programming in C is tested extensively through rigorous code tracing, pointer mechanics, and fundamental semantics rather than high-level syntax trivia. GATE tests Recursion primarily through direct execution tracing of recursive C code snippets, stack-unwinding behavior (pre-order vs. Binary Search Trees (BSTs) in GATE CS test a balance of traversal mechanics, structural properties, worst-case vs.
Core concepts
- Pointer arithmetic and scale factors based on base type
- Multidimensional array decaying into pointers (pointer to array vs array of pointers)
- Storage classes (auto, register, static, extern) and lifetime vs scope
- Pre-increment vs post-increment evaluation and sequence point rules
- Short-circuit evaluation of logical AND (&&) and logical OR (||)
- Pass-by-value vs pass-by-reference/pointer mechanics
- Recursive call stack tracking with local vs static state retention
- Dynamic memory management (malloc, free, memory leaks, dangling pointers)
- String literals, ASCII arithmetic, character pointers, and null termination ('\0')
- Bitwise operators (&, |, , >) and binary number manipulation
- Switch-case fall-through behavior without break statements
- Recursive function execution and call stack reduction
How questions show up
Pointer Arithmetic and Multidimensional Array Indexing
Commonmixed2 marks2026, 2025, 2024, 2022Evaluating complex pointer expressions involving 1D/2D/3D arrays, array decaying, pointer subtraction, array subscript commutativity (), and double dereferencing ().
Storage Classes, Variable Scope, and Shadowing
CommonNAT2 marks2026, 2023, 2020, 2019Tracing code containing static local variables retaining state across multiple recursive or iterative function calls, global vs local variable shadowing, and lifetime vs scope distinctions.
Parameter Passing and Pointer Swapping Idioms
Commonmixed1 marks2026, 2025, 2024, 2019Testing the distinction between pass-by-value and pass-by-reference using pointers, including classic traps where pointer formal parameters are reassigned locally without dereferencing.
Short-Circuit Evaluation, Precedence, and Side Effects
Commonmixed1 marks2024, 2022, 2021, 2017Evaluating expressions involving logical operators (&&, ||) where side-effects like pre/post increment (++i, i++) or assignment are skipped due to short-circuiting, or custom operator precedence tables.
Loop Invariants, Algorithm Semantics, and Verification
OccasionalMCQ2 marks2025, 2024, 2017, 2016Formulating correct pre/post-conditions, identifying loop invariants (e.g., division by repeated subtraction, binary exponentiation), or filling missing loop termination/update guards.
String Manipulation and Null Termination Pitfalls
Occasionalmixed1 marks2025, 2024, 2017, 2015Tracing pointer-based string copies or scans that miss copying the null terminator '\0', unsigned size_t differences producing underflow, or ASCII arithmetic offsets.
High-yield formulas
Pointer Subtraction
Used when computing the numerical result of subtracting two pointers pointing to elements of the same array.
2D Array Element Address Calculation
Used for mapping multi-dimensional array indices to flat memory offsets in row-major layout.
Array Subscript Equivalence
Used to resolve commutative and unorthodox array indexing expressions in C snippets.
Cyclomatic Complexity
Used to calculate McCabe's cyclomatic complexity where is the count of predicate/decision conditions in the control flow.
Integer Division Loop Invariant
Used to verify formal loop invariants in repeated subtraction integer division routines.
Euclidean Subtraction GCD
Used when analyzing recursive functions that reduce two numbers by repeated subtraction until equality or 1 is reached.
Total Invocations Recurrence
Used to count the total number of function activations including base cases (e.g., ).
Digit Sum in Base $r$
Used when recursive functions peel off least significant digits/bits via modulo and integer division.
Examiner traps in Programming and Data Structures
- Assuming pointer subtraction returns byte difference rather than the number of typed elements.
- Forgetting switch-case fall-through when break statements are omitted.
- Evaluating the right operand of && or || when the left operand already determines the result (short-circuit skipping side-effects like i++).
- Confusing (*p)++ (incrementing the dereferenced value) with *p++ (dereferencing current address then advancing pointer).
- Forgetting that static local variables in recursive functions retain cumulative updates across all activation records.
- Overlooking missing null terminators ('\0') in manual string copying loops, causing trailing characters to persist in memory.
- Failing to account for unsigned arithmetic wrap-around when subtracting unsigned types like sizet from strlen().
- Thinking a function that takes pointer parameters swaps them in main when the function swaps pointer values locally instead of dereferenced targets.
Paper trends
Shift towards Numerical Answer Type (NAT) questions requiring exact printed output calculations rather than multiple-choice guessing.
2026, 2025, 2023, 2021, 2020, 2019, 2018, 2017, 2015
Introduction of non-standard operator precedence tables where candidates must compute expression values based on customized grammar rules rather than default C precedence.
2024
Inclusion of Multi-Select Questions (MSQ) examining algorithmic invariants, asymptotic function bounds, and string pointer validity across multiple scenarios.
2024
Increased focus on subtle C standard specifications such as unsigned arithmetic wrap-around with strlen(), uninitialized struct next pointer dereferencing, and block-scope variable shadowing.
2026, 2025, 2024, 2021, 2017