Home › GATE CS › PYQs › Programming & Data Structures

Programming & Data Structures — GATE CS Previous Year Questions

Practise GATE Programming & Data Structures previous year questions, organized by topic. Filter by year, marks and MCQ, MSQ or NAT question type. Browse free previews; full access may require a paid plan.

Mapped syllabus topics

  • Programming in C
  • Recursion
  • Arrays, Stacks, Queues & Linked Lists
  • Trees, Binary Search Trees & Binary Heaps
  • Graphs

Public question previews

  • Let n be an odd number greater than 100. Consider a binary minheap with n elements stored in an array P whose index starts from 1. Which of the following indices of P do/does NOT correspond to any leaf node of the minheap? (2026 · 1 mark · MSQ)
  • Consider the following C statements: char *str1 = "Hello; /* Statement S1 */ char *str2 = "Hello;"; /* Statement S2 */ int *str3 = "Hello"; /* Statement S3 */ Which of the following options is/are correct? (2026 · 1 mark · MSQ)
  • The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with 23 nodes is _________. (answer in integer) (2026 · 1 mark · NAT)
  • Consider the following program in C: #include <stdio.h> void func(int i, int j) { if(i < j) { int i = 0; while (i < 10) { j += 2; i++; } } printf("%d", i); } int main() { int i = 9, j = 10; func(i, j); return 0; } The output of the program is _________. (answer in integer) Note: Assume that the program compiles and runs successfully. (2026 · 1 mark · NAT)
  • Consider the following code snippet in C language that computes the number of nodes in a non-empty singly linked list pointed to by the pointer variable head. struct node{ int elt; struct node *next; }; int getListSize (struct node *head) { if( E1 ) return 1; return E2; } Which one of the following options gives the correct replacements for the expressions E1 and E2? (2026 · 2 marks · MCQ)