🇮🇳 GATE DA & AI Engineering · flashcards

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

52 question-and-answer cards covering Programming, Data Structures and Algorithms as it is examined in GATE DA & AI Engineering. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

52Cards in deck
24Free preview
6Syllabus topics
~208Chars per answer
FreePrice

24 sample cards from the Programming, Data Structures and Algorithms deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. 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.

  2. 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.

  3. 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$.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. 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.

  13. 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.

  14. 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))$.

  15. 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.

  16. 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.

  17. 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).

  18. 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.

  19. 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.

  20. 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.

  21. 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.

  22. 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).

  23. 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.

  24. 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.

What this deck covers

The Programming, Data Structures and Algorithms deck follows the GATE DA & AI Engineering Programming, Data Structures and Algorithms syllabus — 1 chapters and 6 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 52.0 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 208 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Programming, Data Structures and Algorithms flashcards FAQ

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

52 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these GATE DA & AI Engineering flashcards free?

Yes. The preview here is free to read with no signup, and the full 52-card deck is free inside the Examius app.

What do the Programming, Data Structures and Algorithms cards cover?

They follow the GATE DA & AI Engineering Programming, Data Structures and Algorithms syllabus — 1 chapters and 6 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.