About

Exam Practice

Master algorithm efficiency analysis, recurrences, combinatorial generation, divide-and-conquer, and midterm exam problems based on Levitin (3rd ed).

Reference text: Introduction to the Design and Analysis of Algorithms, 3rd Edition (Anany Levitin)

Showing 12 cards
Asymptotics & Loop Analysis

Big-O Notation: O(g(n))O(g(n))

termtap to reveal ↺
Definition

t(n)∈O(g(n))t(n) \in O(g(n)) means t(n)≤c⋅g(n)t(n) \le c \cdot g(n) for all n≥n0n \ge n_0. Represents an asymptotic upper bound.

Big-O Notation: O(g(n))O(g(n))tap to flip back ↺
Asymptotics & Loop Analysis

Big-Omega Notation: Ω(g(n))\Omega(g(n))

termtap to reveal ↺
Definition

t(n)∈Ω(g(n))t(n) \in \Omega(g(n)) means t(n)≥c⋅g(n)t(n) \ge c \cdot g(n) for all n≥n0n \ge n_0. Represents an asymptotic lower bound.

Big-Omega Notation: Ω(g(n))\Omega(g(n))tap to flip back ↺
Asymptotics & Loop Analysis

Big-Theta Notation: Θ(g(n))\Theta(g(n))

termtap to reveal ↺
Definition

t(n)∈Θ(g(n))t(n) \in \Theta(g(n)) means c1⋅g(n)≤t(n)≤c2⋅g(n)c_1 \cdot g(n) \le t(n) \le c_2 \cdot g(n) for all n≥n0n \ge n_0. Represents an asymptotically tight bound.

Big-Theta Notation: Θ(g(n))\Theta(g(n))tap to flip back ↺
Asymptotics & Loop Analysis

Basic Operation

termtap to reveal ↺
Definition

The most significant operation executed in the innermost loop that contributes most to total running time.

Basic Operationtap to flip back ↺
Introduction & Data Structures

Sieve of Eratosthenes

termtap to reveal ↺
Definition

Algorithm to list all primes up to nn by iteratively marking multiples of each prime pp starting at p2p^2. Runs in Θ(nlog⁡log⁡n)\Theta(n \log \log n) time.

Sieve of Eratosthenestap to flip back ↺
Mathematical Analysis & Summations

Tower of Hanoi Recurrence

termtap to reveal ↺
Definition

T(n)=2T(n−1)+1T(n) = 2T(n-1) + 1 with T(1)=1T(1) = 1. Requires exactly 2n−12^n - 1 disk moves.

Tower of Hanoi Recurrencetap to flip back ↺
Brute Force & Exhaustive Search

Convex Hull

termtap to reveal ↺
Definition

The smallest convex polygon enclosing a given set of points. The vertices of this polygon are extreme points.

Convex Hulltap to flip back ↺
Brute Force & Exhaustive Search

Assignment Problem Complexity

termtap to reveal ↺
Definition

Assigning nn people to nn jobs with an n×nn \times n cost matrix has n!n! candidate permutations; exhaustive search takes Θ(n!)\Theta(n!) time.

Assignment Problem Complexitytap to flip back ↺
Decrease-and-Conquer

Mobile Element (Johnson-Trotter)

termtap to reveal ↺
Definition

An integer in a directed permutation that points to an immediately adjacent neighbor with a strictly smaller value.

Mobile Element (Johnson-Trotter)tap to flip back ↺
Divide-and-Conquer & Master Theorem

Master Theorem

termtap to reveal ↺
Definition

For T(n)=aT(n/b)+Θ(nd)T(n) = aT(n/b) + \Theta(n^d): Θ(nd)\Theta(n^d) if a<bda < b^d; Θ(ndlog⁡n)\Theta(n^d \log n) if a=bda = b^d; Θ(nlog⁡ba)\Theta(n^{\log_b a}) if a>bda > b^d.

Master Theoremtap to flip back ↺
Divide-and-Conquer & Master Theorem

Karatsuba Multiplication

termtap to reveal ↺
Definition

Multiplies two nn-digit numbers using 3 recursive half-size multiplications instead of 4, running in Θ(nlog⁡23)≈Θ(n1.585)\Theta(n^{\log_2 3}) \approx \Theta(n^{1.585}).

Karatsuba Multiplicationtap to flip back ↺
Divide-and-Conquer & Master Theorem

Merge Sort vs Quick Sort

termtap to reveal ↺
Definition

Merge Sort is stable with guaranteed Θ(nlog⁡n)\Theta(n \log n) and Θ(n)\Theta(n) extra space. Quick Sort is in-place and faster on average, but has Θ(n2)\Theta(n^2) worst case.

Merge Sort vs Quick Sorttap to flip back ↺