GATE CSE 2027 Programming and Data Structures: Syllabus, Weightage, C, Trees, Heaps & Solved Problems
The highest-weight subject in GATE CSE. C output prediction, recursion tracing, stacks, queues, linked lists, trees, BSTs, heaps and graphs, with the facts and worked questions you need for 2027.
By Piyush Wairale (M.Tech, IIT Madras) · Former Instructor, IIT Madras BS Degree Programme · Mentor to 20,000+ GATE aspirants · Updated November 2026
Quick Answer
• Programming and Data Structures is Section 4 of GATE CSE 2027 and typically carries 10 to 12 marks, more than any other technical subject.
• Syllabus: Programming in C, recursion, arrays, stacks, queues, linked lists, trees, binary search trees, binary heaps and graphs.
• Most questions are output prediction (C code with pointers, recursion, static variables) and counting/structure questions on trees and heaps.
• Tracing code fast and correctly is a trained skill: build it with the GATE CSE 2027 Test Series by Piyush Wairale.
🎯 Test your Programming & DS today
Subject-wise tests + full-length GATE CSE mocks with MCQ, MSQ and NAT questions, detailed solutions and performance analysis. Only ₹499 ₹999.
Join GATE CSE 2027 Test Series →On this page
Official syllabus · Weightage · C & recursion · Arrays, stacks, queues, lists · Trees & BSTs · Heaps · Graphs · Solved problems · Strategy · FAQs
GATE CSE 2027 Programming and Data Structures Syllabus (Official, IIT Madras)
Section 4 of the CS paper: Programming in C. Recursion. Arrays, stacks, queues, linked lists, trees, binary search trees, binary heaps, graphs.
See all sections in the GATE CS 2027 syllabus and exam pattern guide.
Topic-wise Weightage and Priority
| Topic | Typical question | Priority |
|---|---|---|
| C programming & recursion | Output of code with pointers, arrays, static vars, recursion | Very high |
| Trees & BSTs | Traversals, reconstruction, node/height counts, BST insertion order | Very high |
| Binary heaps | Array after insert/delete, build-heap, k-th smallest | High |
| Stacks & queues | Infix/postfix, stack permutations, circular queue conditions | High |
| Linked lists & graphs | Pointer manipulation code, adjacency representations | Medium |
Programming in C and Recursion
GATE C questions test semantics, not syntax. Master: pointer arithmetic (p + 1 moves by sizeof(*p) bytes), arrays vs pointers (a[i] ≡ *(a + i), and arrays decay to pointers when passed), static variables (initialised once, retain value across calls), call by value (C has no call by reference; you pass addresses), scope and lifetime, operator precedence (*p++ increments the pointer, (*p)++ increments the value), and string handling with the terminating ‘\0’.
For recursion, draw the recursion tree and count calls: for fun(n) = fun(n−1) + fun(n−2), the number of calls grows like Fibonacci. Know tail recursion and how activation records stack up on the call stack.
Arrays, Stacks, Queues and Linked Lists
Arrays: row-major address of A[i][j] = base + ((i − lb1) × columns + (j − lb2)) × element size. Stacks: infix to postfix conversion, postfix evaluation, recursion simulation; the number of valid stack permutations of n elements is the Catalan number Cn. Queues: in a circular queue of size n using the one-empty-slot convention, full is (rear + 1) mod n == front and capacity is n − 1. A queue can be built from two stacks. Linked lists: insertion/deletion code tracing, reversing a list, detecting a cycle (slow and fast pointers), and the O(1) vs O(n) costs at head and tail.
Trees and Binary Search Trees
A binary tree of height h (root at height 0) has at most 2h+1 − 1 nodes. In any binary tree, leaves = nodes of degree 2 + 1. Number of structurally different binary trees with n nodes, and number of BSTs on n distinct keys, are both the Catalan number Cn = (2n)! / ((n+1)! n!). Inorder + preorder (or inorder + postorder) uniquely determines a binary tree; preorder + postorder alone does not (unless the tree is full). Inorder traversal of a BST gives sorted order. BST search, insert and delete are O(h): O(log n) when balanced, O(n) when skewed.
Binary Heaps
A binary heap is a complete binary tree stored in an array: for 1-based index i, children are at 2i and 2i+1, parent at ⌊i/2⌋. Insert and delete-min/max are O(log n); build-heap is O(n) (not O(n log n)); finding the max in a min-heap is O(n) and it lies among the leaves. Height of a heap with n nodes is ⌊log2n⌋.
Graphs as Data Structures
An adjacency matrix uses O(V²) space with O(1) edge lookup; an adjacency list uses O(V + E) space and is better for sparse graphs. Traversal algorithms (BFS and DFS) are covered in the GATE CSE Algorithms guide.
Five GATE-Style Problems, Solved
Q1 (NAT). What does this print?
int a[] = {10, 20, 30, 40, 50};
int *p = a + 1;
printf("%d", *(p + 2) + p[-1]);
Solution: p points to 20. *(p + 2) = 40 and p[−1] = 10. Output: 50.
Q2 (NAT). For int fun(int n) { if (n <= 1) return 1; return fun(n−1) + fun(n−2); }, what is fun(5), and how many calls are made in total?
Solution: Values: fun(2)=2, fun(3)=3, fun(4)=5, fun(5)=8. Calls satisfy C(n) = 1 + C(n−1) + C(n−2) with C(0) = C(1) = 1, so C(5) = 15.
Q3 (NAT). Evaluate the postfix expression 6 2 3 + − 3 8 2 / + *.
Solution: 2+3=5, 6−5=1, 8/2=4, 3+4=7, 1×7 = 7.
Q4 (NAT). How many distinct BSTs can be formed with 4 distinct keys?
Solution: C4 = 8!/(5! · 4!) = 14.
Q5 (NAT). What is the height of a binary heap with 100 nodes (root at height 0)?
Solution: ⌊log2100⌋ = 6.
One wrong pointer step = zero marks. Train your tracing.
The GATE CSE 2027 Test Series has Programming & DS subject-wise tests full of C output, recursion and tree questions, each with a line-by-line solution so you see exactly where your trace went wrong.
Start practising for ₹499 →Common Mistakes to Avoid
Confusing *p++ with (*p)++ and misreading precedence.
Forgetting that static variables persist between recursive calls.
Assuming C passes arrays by value: changes inside the function affect the caller’s array.
Mixing up height conventions (root at height 0 vs 1) in tree formulas; read the question’s definition.
Saying build-heap is O(n log n): bottom-up heapify is O(n).
5-Week Preparation Strategy
Weeks 1 to 2: C programming: pointers, arrays, strings, storage classes, recursion. Trace 100+ small programs by hand. Week 3: Stacks, queues and linked lists. Week 4: Trees, BSTs and heaps, with counting formulas. Week 5: Solve 10 years of GATE CS PDS questions and take the Programming & DS tests in the GATE CSE 2027 Test Series. Continue with Algorithms next.
Best GATE CSE 2027 Test Series by Piyush Wairale (IIT Madras)
Built for Computer Science and IT aspirants who want exam-level practice, not just theory.
✔ Subject-wise tests covering the complete GATE CSE 2027 syllabus
✔ Full-length mock tests on the actual GATE pattern
✔ MCQ, MSQ and NAT questions, exactly like the real exam
✔ Detailed solutions and explanations for every question
✔ Performance analysis to find and fix your weak topics
₹499 ₹999 50% OFF
Enroll in GATE CSE 2027 Test Series →More GATE courses and notes: piyushwairale.com
FAQs: GATE CSE 2027 Programming and Data Structures
How many marks does Programming and Data Structures carry in GATE CSE?
About 10 to 12 marks in recent GATE CS papers, making it the highest-weight technical subject.
Which programming language is asked in GATE CSE 2027?
Only C. The official syllabus lists Programming in C; Python and Java are not part of GATE CS.
Are AVL trees and hashing in Data Structures?
AVL trees are not named in the 2027 syllabus, which lists trees, BSTs and binary heaps. Hashing is listed under the Algorithms section.
Which is the best test series for GATE CSE 2027?
The GATE CSE 2027 Test Series by Piyush Wairale (IIT Madras) on piyushwairale.com offers subject-wise and full-length mocks with MCQ, MSQ and NAT questions, detailed solutions and performance analysis for ₹499. See the test series.
How do I get better at C output questions?
Trace on paper with a memory diagram (variables, addresses, stack frames), never in your head, and practise timed sets until tracing a 15-line program takes under 3 minutes.
GATE CSE 2027: All Subject-wise Guides
1. Engineering Mathematics · 2. Digital Logic · 3. Computer Organization & Architecture · 4. Programming & Data Structures · 5. Algorithms · 6. Theory of Computation · 7. Compiler Design · 8. Operating System · 9. Databases (DBMS) · 10. Computer Networks
Full paper overview: GATE CS 2027 Syllabus, Exam Pattern & Cutoff. Practise all ten subjects in one place with the GATE CSE 2027 Test Series.
Recent Post

GATE CSE 2027 Computer Networks guide: official syllabus, approx. 8 to 9 marks weightage, layering, switching, error detection, MAC and Ethernet, distance vector and link state routing, IPv4, CIDR, NAT, fragmentation, TCP flow and congestion control, DNS and HTTP, solved numericals and the GATE CSE 2027 Test Series.

GATE CSE 2027 DBMS guide: official syllabus, approx. 7 to 8 marks weightage, ER model, relational algebra, tuple calculus, SQL, functional dependencies, normal forms, B and B+ trees, transactions and concurrency control, solved problems and the GATE CSE 2027 Test Series.

GATE CSE 2027 Operating System guide: official syllabus, approx. 9 to 10 marks weightage, processes, threads, fork, CPU scheduling, semaphores, deadlock, paging, virtual memory, page replacement and file systems, solved numericals and the GATE CSE 2027 Test Series.

GATE CSE 2027 Compiler Design guide: official syllabus, approx. 4 to 6 marks weightage, lexical analysis, LL and LR parsing, syntax-directed translation, runtime environments, intermediate code, liveness and constant propagation, solved problems and the GATE CSE 2027 Test Series.

GATE CSE 2027 Theory of Computation guide: official syllabus, approx. 8 marks weightage, regular expressions, DFA/NFA, CFGs, PDAs, pumping lemma, closure properties, Turing machines and undecidability, solved problems and the GATE CSE 2027 Test Series.

GATE CSE 2027 Algorithms guide: official syllabus, approx. 8 to 10 marks weightage, asymptotic analysis, Master theorem, sorting, hashing, greedy, dynamic programming, divide and conquer, BFS/DFS, MST and shortest paths, solved problems and the GATE CSE 2027 Test Series.
Learn Daily, Wherever You Are
Free lectures, exam updates, PYQ discussions, and job alerts — delivered through our YouTube channel and Telegram communities.



[…] · 2. Digital Logic · 3. Computer Organization & Architecture · 4. Programming & Data Structures · 5. Algorithms · 6. Theory of Computation · 7. Compiler Design · 8. […]
[…] · 2. Digital Logic · 3. Computer Organization & Architecture · 4. Programming & Data Structures · 5. Algorithms · 6. Theory of Computation · 7. Compiler Design · 8. […]
[…] then 10 years of GATE CS PYQs and the Algorithms tests in the GATE CSE 2027 Test Series. Make sure Programming & Data Structures is done […]