Practice Problems
Theory without practice is incomplete. This article provides interactive problems covering logic, sets, combinatorics, and graphs — test your understanding with quizzes, code challenges, and worked examples.
Section 1: Logic
Quiz — Truth Tables
Q1.What is the truth value of (T → F) ∧ (F → T)?
Q2.Which logical connective has this truth table: TT→T, TF→T, FT→F, FF→T?
Q3.De Morgan's Law: ¬(p ∧ q) is equivalent to...
Practice — Boolean Simplification
Simplify the following boolean expression using logical equivalences:
Section 2: Sets and Counting
Quiz — Set Operations
Q1.If A = {1,2,3,4} and B = {3,4,5,6}, what is |A ∪ B|?
Q2.How many subsets does a set with 5 elements have?
Q3.C(10, 3) = ?
Code Challenge — Powerset Generator
Write a function that generates the powerset (set of all subsets) of a given set.
Section 3: Combinatorics
The Birthday Problem
What's the probability that in a room of people, at least two share a birthday?
Section 4: Graphs
Quiz — Graph Properties
Q1.A tree with 10 vertices has how many edges?
Q2.What is the maximum number of edges in a simple undirected graph with 6 vertices?
Q3.Which traversal uses a queue?
Code Challenge — Shortest Path
Implement Dijkstra's algorithm for finding the shortest path in a weighted graph.
Summary
Key takeaways from this practice session:
- Logic: Master De Morgan's laws and truth tables — they're the basis of all conditional reasoning
- Counting: The multiplication principle, permutations, and combinations appear in algorithm analysis constantly
- Graphs: Know both BFS and DFS, understand adjacency representations, and practice shortest-path algorithms
- Practice > Theory: The only way to get better is to solve more problems