🇮🇳 GATE CS & IT Engineering · subject

GATE CS & IT Engineering Programming and Data Structures Syllabus

The Programming and Data Structures syllabus for GATE CS & IT Engineering in full: 10 chapters, every one listed below, plus 50 Programming and Data Structures flashcards with answers.

10Chapters
50Flashcards

Programming and Data Structures syllabus: all 10 chapters

Expand any chapter to see its topics and sub-topics.

  1. Programming in C

    overview

    No separate topics listed for this chapter.

  2. Recursion

    overview

    No separate topics listed for this chapter.

  3. Arrays

    overview

    No separate topics listed for this chapter.

  4. Stacks

    overview

    No separate topics listed for this chapter.

  5. Queues

    overview

    No separate topics listed for this chapter.

  6. Linked Lists

    overview

    No separate topics listed for this chapter.

  7. Trees

    overview

    No separate topics listed for this chapter.

  8. Binary Search Trees

    overview

    No separate topics listed for this chapter.

  9. Binary Heaps

    overview

    No separate topics listed for this chapter.

  10. Graphs

    overview

    No separate topics listed for this chapter.

GATE CS & IT Engineering Programming and Data Structures flashcards — 50 questions with answers

  1. In C, what is the difference between an array name and a pointer when used as an operand of the sizeof operator?

    For an array, sizeof returns the total bytes of the whole array ($n \times \text{sizeof(element)}$). For a pointer, sizeof returns only the size of the pointer itself (typically 4 or 8 bytes), regardless of what it points to.

  2. What is the time complexity of accessing the $i$-th element of an array versus a singly linked list?

    Array access is $O(1)$ (random access via base address + $i \times \text{size}$). Singly linked list access is $O(n)$ because you must traverse from the head node.

  3. Define a recursive function and state the two essential components every correct recursion must have.

    A recursive function calls itself to solve smaller instances of a problem. It must have (1) a base case that stops recursion, and (2) a recursive case that progresses toward the base case.

  4. What is the recurrence relation and time complexity of computing the $n$-th Fibonacci number by naive recursion?

    $T(n) = T(n-1) + T(n-2) + O(1)$, which gives exponential time $O(\phi^{n})$ where $\phi = \frac{1+\sqrt{5}}{2}$ (about $O(2^{n})$).

  5. In C, what does the storage class specifier 'static' do to a local variable inside a function?

    It gives the local variable static storage duration: it is initialized once and retains its value between function calls, while still having block scope (only visible inside the function).

  6. What is the output type and behavior of pointer arithmetic: if 'p' is 'int *p' pointing to address 1000, what is 'p + 1' (assume 4-byte int)?

    $p + 1$ yields address $1000 + 1 \times 4 = 1004$. Pointer arithmetic scales by the size of the pointed-to type.

  7. Distinguish call by value from call by reference in C function parameter passing.

    Call by value copies the argument; changes inside the function do not affect the caller. C is strictly call by value, but call by reference is simulated by passing pointers, allowing the function to modify the caller's variable through dereferencing.

  8. What is a stack and which principle does it follow? Name its two primary operations.

    A stack is a linear data structure following LIFO (Last In, First Out). Its primary operations are push (insert at top) and pop (remove from top), both $O(1)$.

  9. What is a queue and which principle does it follow? Name its enqueue/dequeue ends.

    A queue is a linear data structure following FIFO (First In, First Out). Insertion (enqueue) happens at the rear; deletion (dequeue) happens at the front.

  10. Why is a circular queue preferred over a simple linear array queue?

    A circular queue reuses freed slots by wrapping the rear/front indices with modulo arithmetic ($\text{rear} = (\text{rear}+1) \bmod n$), avoiding the false-full condition that wastes space in a linear array queue.

  11. How do you detect 'full' and 'empty' in a circular queue of size $n$ using front and rear pointers (with one slot kept empty)?

    Empty when $\text{front} = \text{rear}$. Full when $(\text{rear}+1) \bmod n = \text{front}$. One slot is sacrificed to distinguish the two states.

  12. Convert the infix expression $A + B \times C$ to postfix (Reverse Polish) notation.

    $A\ B\ C\ \times\ +$. Multiplication has higher precedence, so $B\ C\ \times$ is evaluated first, then added to $A$.

  13. Which data structure is used to evaluate a postfix expression, and what is the basic algorithm?

    A stack. Scan left to right: push operands; on an operator, pop the top two operands, apply the operator, and push the result. The final stack value is the answer.

  14. What is the defining property of a binary search tree (BST)?

    For every node, all keys in its left subtree are smaller than the node's key, and all keys in its right subtree are larger. An inorder traversal yields keys in sorted order.

  15. State the time complexity of search, insert, and delete in a BST in the average and worst case.

    Average case $O(\log n)$ (balanced). Worst case $O(n)$ when the tree degenerates into a skewed/linear chain (e.g., inserting sorted data).

  16. List the three depth-first binary tree traversals and the order in which the root is visited in each.

    Preorder: Root, Left, Right. Inorder: Left, Root, Right. Postorder: Left, Right, Root.

  17. What is the maximum number of nodes in a binary tree of height $h$ (root at height 0)?

    $2^{h+1} - 1$ nodes. Each level $i$ holds at most $2^{i}$ nodes, summed from $i=0$ to $h$.

  18. What is the minimum height of a binary tree with $n$ nodes?

    $h = \lfloor \log_{2} n \rfloor$, equivalently $\lceil \log_{2}(n+1) \rceil - 1$. A complete binary tree achieves this minimum height.

  19. Define a complete binary tree and a full (proper) binary tree.

    A complete binary tree has all levels full except possibly the last, which is filled left to right. A full (proper) binary tree has every node with either 0 or 2 children.

  20. What is a max-heap, and how are parent/child indices computed in a 0-indexed array representation?

    A max-heap is a complete binary tree where every parent $\geq$ its children. For index $i$: parent $= \lfloor (i-1)/2 \rfloor$, left child $= 2i+1$, right child $= 2i+2$.

Show the other 30 Programming and Data Structures flashcards
  1. What are the time complexities of insert, extract-max (delete-max), and build-heap operations on a binary heap?

    Insert: $O(\log n)$. Extract-max: $O(\log n)$. Build-heap from an array: $O(n)$ (not $O(n \log n)$, due to the tighter bound on heapify).

  2. In a singly linked list, what is the time complexity to insert a node at the head versus at the tail (no tail pointer)?

    Insert at head: $O(1)$. Insert at tail without a tail pointer: $O(n)$, since you must traverse to the last node.

  3. What advantage does a doubly linked list have over a singly linked list?

    It allows traversal in both directions and $O(1)$ deletion of a node given only a pointer to it, since each node stores both 'next' and 'prev' pointers.

  4. How does Floyd's cycle detection (tortoise and hare) algorithm detect a loop in a linked list, and what is its complexity?

    Two pointers advance, one by 1 step and one by 2 steps; if they ever meet, a cycle exists. It runs in $O(n)$ time and $O(1)$ space.

  5. What is a hash table and what is the average-case time complexity of search/insert/delete?

    A hash table maps keys to array indices via a hash function for near-constant access. Average case $O(1)$; worst case $O(n)$ when all keys collide into one bucket.

  6. Distinguish separate chaining from open addressing as collision resolution strategies.

    Separate chaining stores colliding keys in a linked list at each bucket. Open addressing stores all keys in the table itself and probes for the next free slot (linear, quadratic, or double hashing).

  7. In open addressing, write the linear probing sequence for a key with hash $h(k)$ in a table of size $m$.

    $h(k, i) = (h(k) + i) \bmod m$ for $i = 0, 1, 2, \dots$ The main drawback is primary clustering.

  8. Define the load factor $\alpha$ of a hash table and its significance.

    $\alpha = \frac{n}{m}$, where $n$ is the number of stored keys and $m$ the number of slots. It measures fullness; expected probe count grows as $\alpha \to 1$, so resizing (rehashing) is triggered at a threshold.

  9. What is double hashing and why does it reduce clustering compared to linear probing?

    It uses a second hash function for the step size: $h(k,i) = (h_1(k) + i \cdot h_2(k)) \bmod m$. Different keys get different probe sequences, eliminating primary clustering.

  10. What is the worst-case and average-case time complexity of Quicksort, and when does the worst case occur?

    Average $O(n \log n)$; worst case $O(n^{2})$ when the pivot is always the smallest or largest element (e.g., already-sorted input with naive pivot choice).

  11. State the time complexity of Merge Sort in all cases and its space complexity.

    Merge Sort is $O(n \log n)$ in best, average, and worst cases. It requires $O(n)$ auxiliary space, making it not in-place.

  12. Which common sorting algorithms are stable, and what does stability mean?

    Stability means equal keys retain their original relative order. Stable: Merge Sort, Insertion Sort, Bubble Sort, Counting Sort. Unstable: Quicksort, Heapsort, Selection Sort (in typical implementations).

  13. What recurrence describes Merge Sort, and what is its solution by the Master Theorem?

    $T(n) = 2T(n/2) + O(n)$. With $a=2$, $b=2$, $f(n)=n$, this is Case 2 of the Master Theorem, giving $T(n) = O(n \log n)$.

  14. State the Master Theorem cases for $T(n) = aT(n/b) + f(n)$ with $c = \log_b a$.

    Compare $f(n)$ with $n^{c}$: if $f(n)=O(n^{c-\epsilon})$ then $T(n)=\Theta(n^{c})$; if $f(n)=\Theta(n^{c})$ then $T(n)=\Theta(n^{c}\log n)$; if $f(n)=\Omega(n^{c+\epsilon})$ (and regularity holds) then $T(n)=\Theta(f(n))$.

  15. What is the time complexity of binary search, and what precondition must the input satisfy?

    $O(\log n)$. The input array must be sorted. The recurrence is $T(n) = T(n/2) + O(1)$.

  16. Differentiate Big-O, Big-Omega ($\Omega$), and Big-Theta ($\Theta$) asymptotic notations.

    $O$ is an asymptotic upper bound, $\Omega$ is an asymptotic lower bound, and $\Theta$ is a tight bound (both upper and lower, i.e., $f = O(g)$ and $f = \Omega(g)$).

  17. In C, what is the difference between 'char *s = "hello";' and 'char s[] = "hello";'?

    The pointer form points to a read-only string literal (modifying it is undefined behavior). The array form creates a modifiable local copy of the characters on the stack.

  18. What does the C expression '*p++' do, given operator precedence?

    Postfix ++ binds tighter than dereference, so it parses as $*(p\text{++})$: dereference the current $p$, then increment the pointer $p$ (not the value).

  19. What is dynamic memory allocation in C and which functions perform allocation and deallocation?

    Allocating memory on the heap at runtime. malloc/calloc/realloc allocate; free deallocates. malloc leaves memory uninitialized; calloc zero-initializes.

  20. What is a dangling pointer and a memory leak in C?

    A dangling pointer references memory that has been freed or gone out of scope. A memory leak is heap memory allocated but never freed, lost when its last pointer is overwritten.

  21. For an array stored in row-major order with base address $B$, element size $w$, dimensions $m \times n$, give the address of $A[i][j]$.

    $\text{Address} = B + (i \times n + j) \times w$, assuming 0-based indexing.

  22. What is the time complexity to push and pop in a stack implemented using a linked list?

    Both push and pop are $O(1)$, performed at the head of the list, requiring no traversal.

  23. How can a queue be implemented using two stacks, and what is the amortized dequeue cost?

    Use an 'in' stack for enqueue and an 'out' stack for dequeue; when 'out' is empty, transfer all elements from 'in' to 'out' (reversing order). Amortized cost per operation is $O(1)$.

  24. What is the maximum number of leaf nodes in a binary tree of height $h$?

    $2^{h}$ leaf nodes (the entire last level), occurring in a perfect binary tree with root at height 0.

  25. In a binary tree with $n$ internal nodes (each having exactly 2 children), how many leaf nodes are there?

    $n + 1$ leaf nodes. In any full binary tree, the number of leaves equals the number of internal nodes plus one.

  26. What is an AVL tree and what is its balance condition?

    An AVL tree is a self-balancing BST where, for every node, the heights of the two child subtrees differ by at most 1 (balance factor $\in \{-1, 0, +1\}$). It guarantees $O(\log n)$ operations.

  27. What graph traversal uses a queue and what does it compute in an unweighted graph?

    Breadth-First Search (BFS) uses a queue. It computes the shortest path (fewest edges) from the source to all reachable vertices in an unweighted graph, in $O(V+E)$ time.

  28. What data structure underlies Depth-First Search (DFS), and what is its time complexity using adjacency lists?

    A stack (explicit, or the call stack via recursion). DFS runs in $O(V + E)$ time using adjacency lists.

  29. Compare adjacency matrix vs adjacency list representations of a graph in space and edge-lookup time.

    Adjacency matrix: $O(V^{2})$ space, $O(1)$ edge lookup. Adjacency list: $O(V + E)$ space, $O(\deg(v))$ edge lookup. Lists are better for sparse graphs, matrices for dense graphs.

  30. What is tail recursion and why is it significant for optimization?

    Tail recursion is when the recursive call is the last operation in the function. Compilers can optimize it into a loop (tail-call optimization), reusing the same stack frame and reducing space from $O(n)$ to $O(1)$.

GATE CS & IT Engineering Programming and Data Structures FAQ

What is in the GATE CS & IT Engineering Programming and Data Structures syllabus?

GATE CS & IT Engineering Programming and Data Structures is split into 10 chapters: Programming in C, Recursion, Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps and Graphs.

How many chapters are in GATE CS & IT Engineering Programming and Data Structures?

10 chapters.

Are there flashcards for GATE CS & IT Engineering Programming and Data Structures?

Yes — a 50-card Programming and Data Structures deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.