🇮🇳 GATE DA & AI Engineering · subject

GATE DA & AI Engineering Programming, Data Structures and Algorithms Syllabus

The Programming, Data Structures and Algorithms syllabus for GATE DA & AI Engineering in full: 1 chapter, 6 topics and 14 sub-topics, every one listed below, plus 52 Programming, Data Structures and Algorithms flashcards with answers.

1Chapters
6Topics
14Sub-topics
52Flashcards

Programming, Data Structures and Algorithms syllabus: 1 chapter, 6 topics

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

  1. Programming in Python

    6 topics
    • Basic Data Structures
      • Stacks
      • Queues
      • Linked Lists
      • Trees
      • Hash Tables
    • Search Algorithms
      • Linear Search
      • Binary Search
    • Basic Sorting Algorithms
      • Selection Sort
      • Bubble Sort
      • Insertion Sort
    • Divide and Conquer
      • Mergesort
      • Quicksort
    • Introduction to Graph Theory
    • Basic Graph Algorithms
      • Traversals
      • Shortest Path

GATE DA & AI Engineering Programming, Data Structures and Algorithms flashcards — 52 questions with answers

  1. What is a data structure?

    A data structure is a systematic way of organizing, storing, and managing data in memory so it can be accessed and modified efficiently. The choice of structure determines the time and space cost of operations like insertion, deletion, and search.

  2. What is the difference between a linear and a non-linear data structure?

    In a linear data structure (array, stack, queue, linked list) elements are arranged sequentially, each with a single predecessor and successor. In a non-linear data structure (tree, graph) elements are connected hierarchically or in a network, so an element may have many predecessors/successors.

  3. State the abstract behavior (ordering discipline) of a stack.

    A stack is a LIFO (Last-In, First-Out) structure: the last element pushed is the first one popped. All insertions and deletions occur at one end called the top.

  4. Name the core stack operations and their time complexity in an array or linked-list implementation.

    $\text{push}$ (insert at top), $\text{pop}$ (remove top), $\text{peek/top}$ (read top), and $\text{isEmpty}$. Each runs in $O(1)$ time.

  5. Give two classic applications of a stack.

    Function-call management (the runtime call stack / recursion), and expression evaluation and conversion (e.g., infix to postfix, checking balanced parentheses, backtracking, undo operations).

  6. State the abstract behavior (ordering discipline) of a queue.

    A queue is a FIFO (First-In, First-Out) structure: the first element enqueued is the first dequeued. Insertion happens at the rear and removal at the front.

  7. Name the core queue operations and their time complexity.

    $\text{enqueue}$ (insert at rear), $\text{dequeue}$ (remove from front), $\text{front/peek}$, and $\text{isEmpty}$. All run in $O(1)$ time with proper front/rear pointers.

  8. What is a circular queue and why is it used?

    A circular queue treats the underlying array as a ring, where the position after the last index wraps to index $0$. It reuses freed front slots, eliminating the wasted space that a linear array queue suffers after repeated dequeues.

  9. How does a deque differ from an ordinary queue?

    A deque (double-ended queue) allows insertion and deletion at both the front and the rear, generalizing both stacks and queues.

  10. What is a singly linked list and what does each node store?

    A singly linked list is a linear sequence of nodes where each node stores a data field and a single pointer (next) to the following node. The last node's next pointer is null.

  11. Compare the time complexity of access-by-index and insertion-at-head for an array versus a singly linked list.

    Array: random access by index is $O(1)$, but insertion at the head is $O(n)$ (shifting). Linked list: access by index is $O(n)$ (traversal), but insertion at the head is $O(1)$.

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

    Each node also stores a pointer to its predecessor (prev), enabling $O(1)$ bidirectional traversal and $O(1)$ deletion of a node given only a pointer to that node, without traversing from the head.

  13. In a linked list, what is the time complexity of deleting a node when you have a pointer to the node before it?

    $O(1)$ — you simply redirect the predecessor's next pointer past the node to be deleted.

  14. Define a tree as a data structure.

    A tree is a connected, acyclic hierarchical structure of nodes with one designated root, where every non-root node has exactly one parent. A tree with $n$ nodes has exactly $n-1$ edges.

  15. Define the height and depth of a node in a tree.

    The depth of a node is the number of edges on the path from the root to that node (root has depth $0$). The height of a node is the number of edges on the longest downward path from that node to a leaf (leaves have height $0$).

  16. What is a binary search tree (BST) and its ordering property?

    A BST is a binary tree where, for every node, all keys in its left subtree are less than the node's key and all keys in its right subtree are greater. This enables search, insert, and delete in $O(h)$ where $h$ is the height.

  17. What is the search/insert time complexity in a BST in the average versus worst case?

    Average (balanced) case: $O(\log n)$. Worst case (a degenerate/skewed tree resembling a linked list): $O(n)$.

  18. Name the three depth-first traversal orders of a binary tree.

    Inorder (Left, Root, Right), Preorder (Root, Left, Right), and Postorder (Left, Right, Root). For a BST, an inorder traversal visits keys in sorted ascending order.

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

    $2^{h+1} - 1$ nodes (counting height as edges, root at height $0$), which corresponds to a perfect binary tree with $h+1$ levels.

  20. What is a hash table and what is its purpose?

    A hash table stores key–value pairs in an array, using a hash function to map each key to an array index (bucket). It supports average-case $O(1)$ insertion, deletion, and lookup.

Show the other 32 Programming, Data Structures and Algorithms flashcards
  1. What is a hash collision, and name two strategies to resolve it.

    A collision occurs when two distinct keys hash to the same index. Resolution strategies: (1) separate chaining — each bucket holds a linked list of entries; (2) open addressing — probe for another open slot (linear probing, quadratic probing, or double hashing).

  2. Define the load factor of a hash table and its effect on performance.

    The load factor is $\alpha = \frac{n}{m}$, where $n$ is the number of stored entries and $m$ is the number of buckets. As $\alpha$ grows, collisions and average probe length increase, degrading performance; tables are typically resized (rehashed) when $\alpha$ exceeds a threshold.

  3. What are the average and worst-case lookup complexities of a hash table?

    Average case: $O(1)$. Worst case (all keys collide into one bucket): $O(n)$.

  4. What property must a good hash function have?

    It should distribute keys uniformly across buckets (minimizing collisions), be fast (ideally $O(1)$) to compute, and be deterministic — the same key always maps to the same index.

  5. What is searching in the context of algorithms?

    Searching is the process of locating a target element (or determining its absence) within a data collection, returning its position or a found/not-found result.

  6. Describe the linear search algorithm.

    Linear (sequential) search scans elements one by one from the start, comparing each to the target, until a match is found or the list ends. It works on unsorted data.

  7. State the best-, average-, and worst-case time complexity of linear search.

    Best case: $O(1)$ (target is first). Average case: $O(n)$. Worst case: $O(n)$ (target last or absent). Space complexity is $O(1)$.

  8. What precondition must hold for binary search to be applied?

    The data must be sorted (in a known order, e.g., ascending) and randomly accessible by index (as in an array).

  9. Describe one iteration of the binary search algorithm.

    Compute the middle index $mid = \lfloor \frac{low + high}{2} \rfloor$. If $A[mid]$ equals the target, return it. If the target is smaller, search the left half ($high = mid - 1$); if larger, search the right half ($low = mid + 1$). Repeat until the range is empty.

  10. State the time complexity of binary search and the recurrence it satisfies.

    Binary search runs in $O(\log n)$ time, satisfying the recurrence $T(n) = T\!\left(\frac{n}{2}\right) + O(1)$. Space is $O(1)$ iteratively or $O(\log n)$ recursively.

  11. Why is binary search asymptotically faster than linear search?

    Binary search halves the search space each step ($O(\log n)$), exploiting the sorted order, whereas linear search examines elements one at a time ($O(n)$). For large $n$, $\log n \ll n$.

  12. What is a sorting algorithm, and what does 'in-place' mean?

    A sorting algorithm rearranges elements of a collection into a defined order (e.g., ascending). An in-place algorithm sorts using only $O(1)$ (or $O(\log n)$) extra memory beyond the input array.

  13. What does it mean for a sorting algorithm to be stable?

    A stable sort preserves the relative order of elements that have equal keys. Insertion sort, bubble sort, and mergesort are stable; selection sort and standard quicksort are not.

  14. Describe how selection sort works.

    Selection sort repeatedly finds the minimum element from the unsorted portion and swaps it into the next position of the sorted portion, growing the sorted prefix one element per pass.

  15. State the time and space complexity of selection sort.

    Time complexity is $O(n^{2})$ in best, average, and worst cases (the comparisons are unavoidable). Space is $O(1)$. It performs at most $n-1$ swaps.

  16. Describe how bubble sort works.

    Bubble sort repeatedly steps through the list, comparing adjacent elements and swapping them if out of order, so the largest unsorted element 'bubbles' to its correct position each pass. It repeats until no swaps are needed.

  17. State the best-, average-, and worst-case time complexity of bubble sort.

    Best case $O(n)$ (already sorted, with an early-exit optimization), average and worst case $O(n^{2})$. Space is $O(1)$; it is stable.

  18. Describe how insertion sort works.

    Insertion sort builds the sorted array one element at a time: it takes the next element and inserts it into its correct position among the already-sorted prefix by shifting larger elements rightward.

  19. State the best-, average-, and worst-case time complexity of insertion sort.

    Best case $O(n)$ (nearly sorted input), average and worst case $O(n^{2})$. Space is $O(1)$; it is stable and efficient for small or nearly-sorted data.

  20. Among selection, bubble, and insertion sort, which adapts best to nearly-sorted input and why?

    Insertion sort — for nearly-sorted data it does few shifts per element, approaching its best case of $O(n)$. Selection sort is always $O(n^{2})$, and bubble sort only reaches $O(n)$ with an early-exit check.

  21. What is the divide-and-conquer algorithmic paradigm?

    Divide and conquer solves a problem by (1) dividing it into smaller subproblems of the same type, (2) conquering each subproblem recursively, and (3) combining their solutions into the solution of the original problem. Examples: mergesort, quicksort, binary search.

  22. State the Master Theorem form for divide-and-conquer recurrences.

    For $T(n) = a\,T\!\left(\frac{n}{b}\right) + f(n)$ with $a \geq 1$, $b > 1$: compare $f(n)$ to $n^{\log_b a}$. If $f(n)$ is polynomially smaller, $T(n)=\Theta(n^{\log_b a})$; if equal (up to log factors), $T(n)=\Theta(n^{\log_b a}\log n)$; if larger (and regularity holds), $T(n)=\Theta(f(n))$.

  23. Describe the mergesort algorithm.

    Mergesort divides the array into two halves, recursively sorts each half, then merges the two sorted halves into a single sorted array. It is a divide-and-conquer, comparison-based sort.

  24. State the time and space complexity of mergesort.

    Time complexity is $O(n \log n)$ in best, average, and worst cases, from the recurrence $T(n) = 2T\!\left(\frac{n}{2}\right) + O(n)$. Space is $O(n)$ for the auxiliary merge array; it is stable.

  25. Why is mergesort preferred for sorting linked lists or external (disk-based) data?

    Mergesort accesses data sequentially and merges without random access, so it works efficiently on linked lists (no extra space needed for the merge) and on data too large to fit in memory (external sorting).

  26. Describe the quicksort algorithm.

    Quicksort picks a pivot element, partitions the array so that elements smaller than the pivot come before it and larger ones after it (placing the pivot in its final position), then recursively sorts the two partitions. It is in-place and comparison-based.

  27. State the best/average and worst-case time complexity of quicksort, and when the worst case occurs.

    Best and average case: $O(n \log n)$. Worst case: $O(n^{2})$, occurring with consistently unbalanced partitions (e.g., already-sorted input with a fixed first/last pivot). Space is $O(\log n)$ for the recursion stack.

  28. Contrast mergesort and quicksort on worst-case time, space, and stability.

    Mergesort: worst case $O(n \log n)$, needs $O(n)$ extra space, stable. Quicksort: worst case $O(n^{2})$ but $O(n \log n)$ average, in-place ($O(\log n)$ stack), not stable. Quicksort is usually faster in practice due to better cache locality and low constants.

  29. What is a graph, and what are its two fundamental components?

    A graph $G = (V, E)$ is a collection of vertices (nodes) $V$ and edges $E$ connecting pairs of vertices. It models pairwise relationships and may be directed or undirected, weighted or unweighted.

  30. Distinguish a directed graph from an undirected graph, and define the degree of a vertex.

    In an undirected graph edges have no direction (an edge $\{u,v\}$ is bidirectional); a vertex's degree is its number of incident edges. In a directed graph (digraph) edges are ordered pairs $(u,v)$; each vertex has an in-degree (incoming) and out-degree (outgoing).

  31. Compare the space complexity of an adjacency matrix versus an adjacency list for a graph with $V$ vertices and $E$ edges.

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

  32. Compare BFS and DFS graph traversals: data structure used and complexity.

    BFS (Breadth-First Search) explores level by level using a queue and finds shortest paths in unweighted graphs. DFS (Depth-First Search) explores as deep as possible using a stack (or recursion). Both run in $O(V + E)$ time with an adjacency list.

GATE DA & AI Engineering Programming, Data Structures and Algorithms FAQ

What is in the GATE DA & AI Engineering Programming, Data Structures and Algorithms syllabus?

GATE DA & AI Engineering Programming, Data Structures and Algorithms is split into 1 chapter: Programming in Python. Together they contain 6 topics and 14 sub-topics.

How many chapters are in GATE DA & AI Engineering Programming, Data Structures and Algorithms?

1 chapter, containing 6 topics and 14 sub-topics.

Are there flashcards for GATE DA & AI Engineering Programming, Data Structures and Algorithms?

Yes — a 52-card Programming, Data Structures and Algorithms 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.