Computing and Information Technology

Data Structures and Algorithms Practice Exam, Flashcards & Questions

Master foundational to advanced Data Structures and Algorithms with 632 verified curriculum items, worked engineering solutions, and spaced-repetition cards.

442 Total Questions 156 MCQs 198 Calculations 6 Formulas 82 Flashcards
Free Interactive Preview

Data Structures and Algorithms Sample Exam Questions & Rationale

Preview official questions below. The complete pool of 442 items is available in the offline app.

Question 1 of 4 Approximation algorithms

How is the approximation ratio $\alpha$ formally defined for an algorithm solving a minimization problem with solution cost $C$ and optimal cost $C^*$?

A The percentage of problem constraints that are satisfied simultaneously
B The probability that the algorithm produces the exact optimal solution on a random graph
C max(C / C*, C* / C) <= alpha, where alpha >= 1 guarantees that the solution is within a factor of alpha of the optimum
D The ratio of the algorithm's polynomial runtime to the exponential brute-force runtime
Accepted Answer: Option C (max(C / C*, C* / C) <= alpha, where alpha >= 1 guarantees that the solution is within a factor of alpha of the optimum)

Rationale: For minimization, an algorithm has approximation ratio $\alpha$ if $C \leq \alpha C^*$ for all inputs. The factor $\alpha \geq 1$ bounds the worst-case deviation from the true global optimum.

Question 2 of 4 Dijkstra and Bellman-Ford

In Dijkstra's algorithm, edge $(U, V)$ has weight $w(U, V) = 7$. Currently, the tentative shortest distance estimates from source $S$ are $d[U] = 12$ and $d[V] = 25$. Perform the standard edge relaxation step `relax(U, V, w)`. What is the resulting updated value of $d[V]$?

A 19
B 25
C 12
D 7
Accepted Answer: Option A (19)

Rationale: **Given:** Tentative distances: $d[U] = 12$, $d[V] = 25$. Directed edge $(U, V)$ with weight $w = 7$. **Formula:** $\text{relax}(U, V, w): d[V] = \min(d[V], d[U] + w(U, V))$ **Calculation:** $d[U] + w(U, V) = 12 + 7 = 19$. Since $19 < 25$, distance estimate $d[V]$ is updated to $19$. **Answer:** 19

Question 3 of 4 Fast Fourier transform concepts

How does the Fast Fourier Transform (FFT) accelerate polynomial multiplication from naive O(n^2) to O(n log n)?

A It converts polynomial coefficients into floating-point numbers in IEEE 754 format
B It transforms polynomials from coefficient form to point-value form at complex roots of unity in O(n log n), multiplies point values in O(n), and applies inverse FFT in O(n log n)
C It diagonalizes the polynomial companion matrix using Gaussian elimination
D It factors both polynomials into linear irreducible factors using the quadratic formula
Accepted Answer: Option B (It transforms polynomials from coefficient form to point-value form at complex roots of unity in O(n log n), multiplies point values in O(n), and applies inverse FFT in O(n log n))

Rationale: Point-value multiplication of two degree-$n$ polynomials takes only $O(n)$ pointwise products. FFT and inverse FFT compute the discrete Fourier transform and its inverse in $O(n \log n)$ time using the symmetry of roots of unity.

Question 4 of 4 Minimum spanning trees (Prim and Kruskal)

An undirected connected graph contains 5 vertices {A, B, C, D, E} and edges with weights: (A,B,1), (B,C,2), (A,C,2), (C,D,3), (B,D,4), (D,E,5), (C,E,6). Trace Kruskal's algorithm to select edges without cycles. What is the total weight of the resulting Minimum Spanning Tree (MST)?

A 15
B 11
C 10
D 12
Accepted Answer: Option B (11)

Rationale: **Given:** Vertices $V = 5$ (requires $V - 1 = 4$ edges). Sorted edge list: $(A,B,1), (B,C,2), (A,C,2), (C,D,3), (B,D,4), (D,E,5), (C,E,6)$. **Formula:** Kruskal's algorithm greedily adds the lowest-weight edge that does not form a cycle with previously chosen edges. **Calculation:** 1. Select $(A,B,1)$ (weight 1). 2. Select $(B,C,2)$ (weight 2). 3. Inspect $(A,C,2)$: forms cycle $A-B-C-A$, reject. 4. Select $(C,D,3)$ (weight 3). 5. Inspect $(B,D,4)$: forms cycle $B-C-D-B$, reject. 6. Select $(D,E,5)$ (weight 5). Exactly 4 edges selected: $(A,B,1), (B,C,2), (C,D,3), (D,E,5)$. Total weight $= 1 + 2 + 3 + 5 = 11$. **Answer:** 11

Active Recall Spaced Repetition Cards (Preview)

Card 1 • Approximation algorithms
Guaranteeing a tour cost of at most {{c1::2}} times the optimal tour.
Removing an edge from the optimal TSP tour yields a spanning tree, so $\text{weight}(\text{MST}) < C^*$. A full Eulerian walk traverses each MST edge twice ($2 \times \text{MST}$). Triangle inequality shortcuts ensure $C_{\text{tour}} \leq 2 C^*$.
Card 2 • Dijkstra and Bellman-Ford
Dijkstra's single-source shortest path algorithm requires that all edge weights in the graph are strictly {{c1::non-negative}}.
Dijkstra's greedy proof assumes that once a vertex is extracted from the priority queue, its shortest distance is finalized. Negative edges can create shorter paths through previously finalized vertices, violating the greedy invariant.

Data Structures and Algorithms Curriculum Modules & Topics Covered

Modules
Data StructuresAlgorithmsAnalysisAdvanced Algorithms
Core Exam Topics
  • Priority queues
  • Greedy algorithms
  • Binary search
  • Arrays
  • Linked lists
  • Stacks and queues
  • Hash tables
  • Trees
  • Heaps
  • Binary search trees
Learning Objectives
  • Develop core conceptual recall and analytical problem-solving in Data Structures.
  • Develop core conceptual recall and analytical problem-solving in Algorithms.
  • Develop core conceptual recall and analytical problem-solving in Analysis.
  • Develop core conceptual recall and analytical problem-solving in Advanced Algorithms.

Free Downloadable Data Structures and Algorithms Study Packs (.ZIP / .TSV)

Full Spreadsheet Data (TSV)
TSV • 442 items
Complete Course Pack
ZIP • 442 items
Elements (Complete)
ZIP • 442 items
Elements (Mastery)
ZIP • 442 items
Elements (Standard)
ZIP • 442 items
Active Recall Flashcards
ZIP • 442 items
Formula Codex
ZIP • 442 items
Problem Solving (Complete)
ZIP • 442 items
Problem Solving (Mastery)
ZIP • 442 items
Problem Solving (Standard)
ZIP • 442 items
Artificial Intelligence (1,579) Artificial Intelligence and Machine Learning (507) Cloud Computing and DevOps (144) Compiler Design & Formal Languages (1,579) Computational Contact Mechanics: Penalty Function Method, Lagrange Multipliers & Mortar Contact Formulations (128) Computer Engineering & Algorithms (1,365)
Full Question Pool: 442 Verified Items

Unlock All 442 Data Structures and Algorithms Practice Questions

Study the full question pool with 13 active recall battle modes, FSRS v5 spaced repetition, and 1-click printable PDF mock exams with full answer keys on Android and Windows PC.

Get on Google Play (Android) Get on Microsoft Store (Windows PC)