Back to notes
AI Notes2026-05-1114 min read

AI Exam Mega Notes

A polished exam revision note with light-mode and dark-mode editions for search, logic, probability, and belief update topics.

Exam NotesA*MinimaxFOLBayesD-S
ExploreActive: OverviewOverviewFinal 2-Page SheetFormula + ReasoningSolve PlansChapter NotesExam Checklist

Interactive study notes

Visual solve-plans for every major problem in the page

Each problem type now has a clear visual roadmap: what to identify, what to compute, what to prune or compare, and how to present the final answer step by step.

Portfolio dark theme

If the question asks for a path

Write the frontier order, parent links, and final path reconstruction.

If the question asks for a proof or comparison

State the property, then give the shortest valid defense in one or two sentences.

If the question asks for a solved example

Show the data structure after every expansion or assignment so the grader can follow the logic.

Final revision

2-page comprehensive last-minute sheet

Use this as the final pass before exam time. It condenses the full syllabus into two high-density pages.

Final Revision Sheet — Page 1

Search, Adversarial Search, CSP

Uninformed vs Informed Search

  • Uninformed: BFS, DFS, DLS, IDS, UCS (no heuristic guidance).
  • Informed: Greedy Best-First, A*, Beam, AO*, Hill-Climbing (heuristic-driven).
  • BFS is complete + optimal only with uniform step cost; UCS handles non-uniform costs.
  • A*: f(n)=g(n)+h(n), optimal when h is admissible/consistent.
  • Greedy uses only h(n): often fast, not guaranteed optimal.

Core Search Comparison (exam one-liners)

  • BFS: shallowest solution first, memory-heavy.
  • DFS: memory-light, can get stuck deep/infinite without checks.
  • IDS: DFS memory with BFS depth guarantee.
  • UCS: expands least g(n), optimal with positive costs.
  • A*: best practical optimal search when heuristic quality is good.

8-Puzzle / Graph Question Workflow

  • Write initial + goal state, legal moves, and cost model.
  • Track frontier/open list + explored/closed list every expansion.
  • For A*, show g, h (Manhattan), f values at each step.
  • Stop at goal and backtrack parent pointers for final path.
  • If asked failure/case analysis: mention local minima, plateaus, branching effects.

Adversarial Search (Minimax, Alpha-Beta)

  • Alternate MAX/MIN levels; evaluate leaves; propagate up.
  • MAX picks highest child, MIN picks lowest child.
  • Alpha = best already guaranteed for MAX; Beta = best for MIN.
  • Prune when alpha >= beta; pruning changes speed, not final minimax result.
  • Good move ordering => dramatically more pruning.

CSP Formulation

  • CSP = Variables + Domains + Constraints.
  • Goal: complete assignment satisfying all constraints.
  • Binary CSP uses constraint graph; structure can reduce complexity.
  • Backtracking baseline: assign one variable, test consistency, recurse, backtrack on failure.
  • N-Queens, map coloring, scheduling, cryptarithmetic are classic CSP examples.

CSP Heuristics + Propagation

  • MRV: choose variable with fewest legal values.
  • Degree heuristic: tie-break with most constraints on remaining variables.
  • LCV: value that rules out fewest choices for neighbors.
  • Forward Checking: prune neighbor domains after assignment.
  • AC-3 Arc Consistency: remove unsupported values until stable or domain wipeout.

Final Revision Sheet — Page 2

Probabilistic AI, Evolutionary Methods, Logic, Uncertainty

Bayes / Naive Bayes

  • Bayes Rule: P(H|E)=P(E|H)P(H)/P(E).
  • Naive Bayes assumes conditional independence of features given class.
  • Classifier workflow: compute class scores, normalize, pick max posterior.
  • Always write prior, likelihood, evidence term, posterior clearly.
  • Mention assumption explicitly: independence often approximate, still practical.

Bayesian Belief Networks (BBN)

  • DAG where nodes are random variables and edges are dependencies.
  • Joint factorization: product of local conditional probabilities.
  • Inference with evidence: update beliefs via marginalization/conditioning.
  • d-separation gives conditional independence checks.
  • Use BBN when dependencies are structured and interpretable.

Genetic Algorithm (GA)

  • Pipeline: initialize population -> evaluate fitness -> selection -> crossover -> mutation -> next generation.
  • Selection can be roulette-wheel using fitness percentages.
  • Crossover recombines parent genes (e.g., single-point).
  • Mutation maintains diversity and avoids premature convergence.
  • Report best/average fitness trend to show convergence behavior.

Local / Iterative Search Notes

  • Hill-Climbing: move to best neighbor; can fail at local maxima/plateaus/ridges.
  • Beam Search: keeps top-k candidates; faster, can miss optimal path.
  • Min-Conflicts for CSP: iterative repair, very effective for large random n-queens.
  • Use random restart when search gets trapped.
  • State quality metrics must be explicit in answer.

Logic (FOL + 2nd Order)

  • FOL uses predicates over objects with forall/exists quantifiers.
  • Key exam risk: quantifier scope mistakes.
  • Convert natural language -> symbols -> validate with one concrete interpretation.
  • Second-order logic quantifies over predicates/relations (more expressive, harder reasoning).
  • When asked comparison: FOL is often computationally friendlier; SOL is stronger expressively.

Jeffrey's Rule / Dempster-Shafer

  • Jeffrey's rule updates beliefs with soft (uncertain) evidence probabilities.
  • Dempster-Shafer represents belief intervals (belief/plausibility), not single precise probability only.
  • Combination rule fuses evidence and handles conflict mass.
  • Use Bayes for hard evidence, Jeffrey for soft evidence, D-S for explicit ignorance.
  • Always end with interpretation, not just raw numbers.

Last-Minute Exam Output Template

  • 1) Problem model (state/variables/evidence/utilities).
  • 2) Chosen algorithm + why appropriate.
  • 3) Stepwise working table (frontier/domains/probabilities/values).
  • 4) Final answer (path/assignment/posterior/move) with one-line justification.
  • 5) If comparison asked: complexity + optimality + completeness in one compact sentence.

Organized theory bank

Formulas, proof sketches, reasoning relations, and semantic networks

This section consolidates uncertainty math, Markov and MCMC formulas, reasoning taxonomy, and semantic network representation into exam-ready tables and visuals.

Formula bank (core + advanced)

ConceptFormulaUseExam note
Conditional probabilityP(AB)=P(AB)P(B)P(A\mid B)=\frac{P(A\cap B)}{P(B)}When event B is already observedClass example: P(Math|English) = 0.40 / 0.70 = 0.5714 (~57.14%)
Bayes ruleP(HE)=P(EH)P(H)P(E)P(H\mid E)=\frac{P(E\mid H)P(H)}{P(E)}Posterior update after evidenceUse total probability for P(E) if needed
Total probabilityP(E)=iP(EHi)P(Hi)P(E)=\sum_i P(E\mid H_i)P(H_i)Normalization denominator for BayesHypotheses H_i are mutually exclusive and complete
Naive Bayes scoreP(Cx)P(C)jP(xjC)P(C\mid x)\propto P(C)\prod_j P(x_j\mid C)Fast classification with conditional independenceCompute class scores then normalize
Markov chain stepπt+1=πtP\pi_{t+1}=\pi_t PState distribution update in Markov modelsP is transition matrix
Stationary distributionπ=πP,  iπi=1\pi^*=\pi^*P,\;\sum_i \pi_i^*=1Long-run Markov behaviorExists/unique under ergodic conditions
Metropolis-Hastings acceptanceα(xx)=min(1,π(x)q(xx)π(x)q(xx))\alpha(x\to x')=\min\left(1,\frac{\pi(x')q(x\mid x')}{\pi(x)q(x'\mid x)}\right)MCMC sampling when direct sampling is hardAccept move with probability alpha
Jeffrey updatePnew(H)=iPold(HEi)Pnew(Ei)P_{new}(H)=\sum_i P_{old}(H\mid E_i)P_{new}(E_i)Soft/uncertain evidence updatesUnlike Bayes, evidence does not need to be hard-true
Dempster combinationm12(A)=BC=Am1(B)m2(C)1Km_{12}(A)=\frac{\sum_{B\cap C=A}m_1(B)m_2(C)}{1-K}Combine independent evidence sourcesK = conflict mass = sum_{B intersect C = empty} m1(B)m2(C)

Bayes theorem and probability - structured note

Organized from your provided content: uncertainty sources, probability rules, Bayes workflow, independence, Naive Bayes, limitations, and extensions.

1) Probability foundations (what to write first)
  • Axioms: 0 <= P(A) <= 1, P(True)=1, P(False)=0, and sum/product rules.
  • Core rules: P(A and B)=P(A|B)P(B), P(A|B)=P(A and B)/P(B).
  • Marginalization: P(B)=sum_a P(B,a)=sum_a P(B|a)P(a).
  • Always define random variables, domain, prior, and evidence before solving.
2) Bayes inference workflow (exam-safe sequence)
  • State hypothesis H and evidence E clearly.
  • Write Bayes: P(H|E)=P(E|H)P(H)/P(E).
  • Compute P(E) using total probability when multiple causes exist.
  • Normalize posteriors and choose MAP hypothesis if classification is asked.
  • For streaming evidence: posterior at step t becomes prior at step t+1.
3) Independence and Naive Bayes
  • Absolute independence: P(A and B)=P(A)P(B).
  • Conditional independence: P(A and B|C)=P(A|C)P(B|C).
  • Naive Bayes: P(C|x) proportional to P(C) * product_i P(x_i|C).
  • Use log probabilities in implementation to avoid underflow.
  • If features are strongly correlated, Naive Bayes quality may degrade.
4) Limits of simple Bayes and richer models
  • Simple Bayes struggles with interacting causes (e.g., alarm-burglar-earthquake style dependence).
  • Multi-fault and causal chaining need structured models (Bayesian networks).
  • Use Jeffrey update for soft evidence, Dempster-Shafer for ambiguous evidence.
  • Use Bayes factors for model comparison and maximum entropy under constraints.

Key equations (KaTeX)

P(AB)=P(AB)P(B)P(A\mid B)=\frac{P(A\cap B)}{P(B)}
P(HE)=P(EH)P(H)P(E)P(H\mid E)=\frac{P(E\mid H)P(H)}{P(E)}
P(E)=iP(EHi)P(Hi)P(E)=\sum_i P(E\mid H_i)P(H_i)
Posterior Odds=Prior Odds×Likelihood Ratio\text{Posterior Odds} = \text{Prior Odds}\times\text{Likelihood Ratio}
P(Cx)P(C)iP(xiC)P(C\mid x)\propto P(C)\prod_i P(x_i\mid C)
logP(Cx)=logP(C)+ilogP(xiC)  (up to constant)\log P(C\mid x)=\log P(C)+\sum_i \log P(x_i\mid C)\;\text{(up to constant)}

Bayesian method map (when to use what)

MethodEvidence typeUpdate ideaBest use
Bayes theoremCertain evidencePosterior proportional to Likelihood x PriorDiagnosis, inference, classification
Law of total probabilityAnyDecompose evidence across causesDenominator/normalization in Bayes
Odds form BayesCertain evidencePosterior odds = Prior odds x likelihood ratioMedical/legal evidence strength
Jeffrey ruleSoft/uncertain evidenceWeighted update over revised evidence probabilitiesBelief revision with noisy observations
Sequential BayesTime-sequenced evidencePosterior becomes next priorFiltering and online inference
Bayes factorObserved dataRelative support BF = P(E|H1)/P(E|H0)Model/hypothesis comparison
Dempster-ShaferPartial/ambiguous evidenceBelief over sets + conflict-aware combinationSensor fusion and ambiguous AI evidence
Maximum entropyConstraint-basedChoose least-biased distribution satisfying constraintsInference with incomplete info constraints
One-line summary: Bayes theorem is the core update rule; extensions handle soft evidence (Jeffrey), sequential evidence, model comparison (Bayes factor), ambiguity (Dempster-Shafer), and constraint-driven inference (maximum entropy).
Bayes normalization proof sketch
  1. Start from definition: P(H|E) = P(H and E)/P(E).
  2. Apply product rule: P(H and E) = P(E|H)P(H).
  3. Substitute and normalize using P(E) from total probability.
Metropolis-Hastings detailed-balance sketch
  1. Transition kernel uses proposal q and acceptance alpha.
  2. Show pi(x)T(x,x') = pi(x')T(x',x) by alpha ratio construction.
  3. Hence pi is stationary; chain samples target distribution asymptotically.
Markov convergence sketch (exam level)
  1. For ergodic chains (irreducible + aperiodic), repeated multiplication by P mixes distributions.
  2. Distance between pi_t and pi* decreases with t.
  3. Therefore pi_t converges to unique stationary pi* independent of start.
A* optimality sketch (admissible h)
  1. Admissible h never overestimates true remaining cost.
  2. So f(n)=g(n)+h(n) is a lower bound on solution cost through n.
  3. When goal is popped first from OPEN, no cheaper solution can remain.

Reasoning types and relations

TypeFlowConclusion statusExample
DeductiveGeneral -> specificCertain if premises trueAll humans are mortal; Suresh is human; so Suresh is mortal.
InductiveSpecific -> generalProbableObserved many white pigeons; infer pigeons are white.
AbductiveObservation -> best explanationMost likely, not guaranteedGround is wet; maybe it rained.
Common-senseHeuristic everyday inferencePractical, context-basedFire burns hand; one person cannot be in two places at once.
MonotonicConclusions never retractStable under added factsEarth revolves around Sun remains true after adding facts.
Non-monotonicConclusions may retractRevision-friendlyBirds fly; Pitty bird -> flies; add Pitty penguin -> does not fly.
Deductive vs Inductive quick relation: deductive is top-down and validity-focused; inductive is bottom-up and probability-focused.

Semantic network (organized)

Semantic networks store knowledge as nodes (objects/concepts) and arcs (relations like IS-A, OWNED-BY, COLOR). They are intuitive but lack standard quantifier handling and can be expensive to traverse.

IS-AIS-AIS-AOWNED-BYCOLORJerryCatMammalAnimalPriyaBrown

Statements encoded

  • Jerry IS-A Cat
  • Cat IS-A Mammal
  • Mammal IS-A Animal
  • Jerry OWNED-BY Priya
  • Jerry COLOR Brown

Advantages vs drawbacks

  • Natural and transparent representation.
  • Easy to extend with new nodes/arcs.
  • Runtime traversal can be expensive in worst case.
  • No strict standard for link naming and quantifiers.

Interactive Lab

Step by step algorithm visualizations

Each widget shows the frontier, bounds, pruning, and backtracking steps. Use the controls to replay every decision the algorithm makes.

Toggle play, adjust speed, and inspect every step.

A* Search Visualization

General weighted graph with cycles and costs.
Normal case
Balanced branching with no special bias.
Why it fails/struggles: A* behaves as expected with moderate expansions and mixed branches.
What to do: Track frontier ordering and parent updates to keep reasoning consistent.
Suggested replacement: Use IDA* or SMA* when memory is the main constraint.
Node badges show per-step values (f/g/h) for the currently active frontier and recent expansions.
Current expandingTraversedFrontier / untraversed
242734272323623262Ah=7f=7Bh=6Ch=5Dh=3Eh=4Fh=2Gh=0
Speed
Step 1 of 42 • Speed 1.00x
Node & edge editor
Drag nodes, adjust heuristics, and manage edges
Double-click a node in the graph to select it for editing.
Edge controls
AB (cost 2)
AC (cost 4)
Order of operations
Showing steps 1 → 1 of 42
1. Initialize AStart node is added to frontier.

Search technique

Informed
Strategy: Lowest f(n)=g+h
Type: Trajectory-based
Best use: Optimal search with admissible heuristic

State graph snapshots (calculation view)

1–2 representative states
State 1: Initialize A
ABCDEFG
Ag=0h=7f=7
State 2: Expanding A
ABCDEFG
Ag=0h=7f=7

All algorithms quick comparison

AlgorithmFamilyTypical problemsUse whenCompleteOptimalTimeSpaceTrajectoryReplacement
BFSUninformed (Blind)Unweighted shortest path, level-order traversal, minimum moves puzzlesShortest path in unit-cost graphsYesYes (if cost=1)O(b^d)O(b^d)Trajectory-basedUse UCS/A* when costs vary; BFS is only step-optimal for uniform costs.
DFSUninformed (Blind)Backtracking, maze traversal, topological-style deep explorationMemory-limited deep explorationNo (infinite loops)NoO(b^m)O(bm)Trajectory-basedUse IDS or A* when completeness and reliable optimality matter.
UCSUninformed (Cost-based)Weighted shortest path, route planning with varying costsOptimal path with varying edge costsYesYesO(b^(C*/e))O(b^(C*/e))Trajectory-basedUse A* with admissible heuristic to reduce expansions.
Best FirstInformedFast heuristic routing, rough path planningFast guided explorationNoNoO(b^m)O(b^m)Trajectory-basedUse A* to combine heuristic guidance with path-cost awareness.
Greedy Best FirstInformedQuick approximate search, low-latency navigationQuick approximate route searchNoNoO(b^m)O(b^m)Trajectory-basedUse A* or UCS if greedy gets trapped by misleading heuristics.
A*InformedOptimal pathfinding, maps/robot navigation with heuristicsOptimal search with admissible heuristicYesYesO(b^d)O(b^d)Trajectory-basedUse IDA* or SMA* when memory is the main constraint.
IDSUninformed (Hybrid)Unknown solution depth with limited memoryBFS-like completeness with DFS spaceYesYes (if cost=1)O(b^d)O(bd)Trajectory-basedUse A* when heuristic quality can cut repeated depth iterations.
IDA*Informed (Memory-aware)Heuristic search under tight memoryA*-style optimality with low memoryYesYesO(b^d)O(bd)Trajectory-basedUse A* if memory permits and repeated re-expansion is too costly.
SMA*Informed (Memory-bounded)Memory-bounded optimal heuristic searchHeuristic search under memory constraintsYes (if mem>d)Yes (if mem)O(b^d)O(M)Trajectory-basedUse A* when memory is enough; use IDA* if memory is very tight.
AO*Informed (AND-OR)AND/OR planning, diagnosis, decomposition with required subgoalsProblems with mandatory AND subgoalsYesYesO(b^d)O(bd)Trajectory-basedUse dynamic programming over solved subgraphs if dependencies are repeated.
BeamInformed (Approximate)Large-branching approximate search, sequence decodingLarge branching with strict runtime limitsNoNoO(w*b*m)O(w*b)Trajectory-basedUse A* or increase beam width when pruning loses solution paths.
HillLocal SearchLocal optimization, scheduling/tuning with iterative improvementOptimization when only final state mattersNoNoO(∞)O(b)Non-trajectoryUse simulated annealing / genetic search / random restarts for local maxima.

Study plan — A*

Based on selected algorithm
Typical problems
  • Heuristic-guided pathfinding
  • Route planning with admissible heuristic
Recommended approach
Use f(n)=g(n)+h(n) ordering; ensure heuristic is admissible to preserve optimality.
Exam tips
  • Display g/h/f values per node
  • Show how heuristic improves pruning vs blind search

Properties (A*) -

CompletenessiYesOptimalityiYesTime ComplexityiO(b^d)Space ComplexityiO(b^d)
b = branching factor, d = depth of optimal solution, m = max tree depth.
Calculation
A: f(n) = g(n) + h(n) = 0 + 7 = 7

Pseudocode

function AStar(problem):
node = node(problem.initial)
frontier = [node]
explored = []
while frontier not empty:
node = pick_next(frontier) // pq.push(child, g+h)
if problem.isGoal(node.state):
return path
explored.push(node.state)
for child in expand(node):
score = priority(child)
if child not in explored:
frontier.push(child, score)
return failure
Live State:
Open: A
Closed:

Search

8-Puzzle with suitable search algorithms

Compare BFS, A*, Greedy, IDA*, Backtracking Search, and Hill Climbing Search on the same puzzle.

1
2
3
4
6
7
5
8
Initialize
Frontier size
2
Explored nodes
1
Use f(n) = g(n) + h(n), with Manhattan distance as h(n).
Speed
Step 1 of 3 • Speed 1.00x

Adversarial

Minimax with alpha beta bounds

Track node values, alpha and beta bounds, and pruned branches as the tree is evaluated.

MAX levelMIN levelMAX levelLEAF levelMAXA-MINB-MINC-MAXD-MAXE-MAXF-MAXG-LEAFH3LEAFI12LEAFJ8LEAFK2LEAFL4LEAFM6LEAFN14LEAFO5

Step detail

Initialize

Root MAX node starts with alpha=-inf, beta=inf

Alpha: -Infinity | Beta: Infinity

Leaf values

Speed
Step 1 of 32 • Speed 1.00x
Chess and Checkers
Classic minimax with alpha beta pruning.
Tic-tac-toe
Small game tree for exact minimax.
Connect Four
Pruning matters due to deeper branching.

CSP

Backtracking with domain pruning

Track MRV selection, domain pruning, and explicit backtracking steps.

Domain size
SAWANTQNSWVT

Step detail

Initialize

Domain size = 4

Domains

SA
Red, Green, Blue, Gold
WA
Red, Green, Blue, Gold
NT
Red, Green, Blue, Gold
Q
Red, Green, Blue, Gold
NSW
Red, Green, Blue, Gold
V
Red, Green, Blue, Gold
T
Red, Green, Blue, Gold
Speed
Step 1 of 23 • Speed 1.00x
Sudoku 4x4
Initialize
1
23
23
4
23
234
1
3
23
1
34
3
4
3
3
2
4x4 Sudoku
Speed
Step 1 of 6 • Speed 1.00x
N-Queens (4)
Initialize
4-Queens problem
Speed
Step 1 of 66 • Speed 1.00x
Constraint Satisfaction Problem (CSP) Fundamentals
State Definition: Variables X₁, X₂, ..., Xₙ with domains D₁, D₂, ..., Dₙ (sets of possible values)
Goal Test: Set of constraints specifying allowable combinations of values for subsets of variables
Key Insight: Unlike standard search, CSPs have structured representation enabling general-purpose algorithms more powerful than blind search.
Search & Backtracking
  • Backtracking: DFS with single-variable assignment per node (b = d, not n!d^n)
  • Variable Selection: MRV heuristic (choose var with fewest legal values)
  • Degree Heuristic: Tie-breaker: most constraints on remaining variables
  • Value Ordering: Least-constraining value (rules out fewest remaining values)
Constraint Propagation
  • Forward Checking: Track remaining legal values for unassigned variables; fail if any empty
  • Arc Consistency (AC-3): X→Y consistent iff ∀x ∈ domain(X) ∃y ∈ domain(Y) satisfying constraint
  • Iterative Deepening: Apply AC-3 as preprocessor or after each assignment
  • Min-Conflicts: Iterative repair for complete-state formulation; near-constant time for n-queens
Exploiting Problem Structure
  • Independent Components: Identify connected components in constraint graph; solve separately
  • Tree-Structured: Solvable in O(n·d²) (vs O(d^n) for general CSPs)
  • Cutset Conditioning: Instantiate variables to make remainder a tree; runtime O(d^c · (n-c)·d²)
Constraint Types & Varieties
  • Unary: Single variable (e.g., SA ≠ green)
  • Binary: Two variables (e.g., SA ≠ WA)
  • Higher-order: 3+ variables (e.g., cryptarithmetic column constraints)
  • Soft: Preferences with costs (constrained optimization)
Real-World CSP Applications
Assignment (who teaches what)
Timetabling (class when/where)
Hardware config
Spreadsheets
Transportation scheduling
Factory scheduling
Floorplanning
Job scheduling
Satellite observation
Map coloring
Constraint graph with small domains.
Sudoku
Row, column, subgrid constraints with MRV.
N-Queens
Row by row backtracking with conflicts.
Timetabling
Classes, rooms, time slots, constraints.
Cryptarithms
Digit assignment with carry rules.
Scheduling
Task order with precedence constraints.

CSP

N-Queen with suitable algorithms

Visual trace for Backtracking, Min-Conflicts, and Branch-and-Bound.

Current step
Initialize
Conflict count
0
Start from row 1 and place safe queens row by row.
Speed
Step 1 of 4 • Speed 1.00x

Evolutionary Optimization

Modern Genetic Algorithm Simulator

Full phase-based simulator for the 8-queens chromosome workflow.

Generation 1
Step 1/5 • Population
Population setup
  • Chromosomes encode queen-row positions for columns 1..8.
  • You can edit genes directly and see immediate fitness changes.
  • Fitness is computed as 28 - attacking queen pairs.
Total fitness (Σf): 78
Best individual: P1
Best fitness: 24
IndividualGene 1Gene 2Gene 3Gene 4Gene 5Gene 6Gene 7Gene 8Fitness
P124
P223
P320
P411

Probability

Bayes, Markov, and Naive Bayes math

Step through the math that drives posterior updates and transition models.

Bayes update
Set priors
P(D) = 0.03
P(+|D) = 0.95
P(-|not D) = 0.92
Bayes probability table
TermValue
P(D)0.030
P(+|D)0.950
P(+|not D)0.080
P(+)0.106
P(D|+)0.269
Prior P(D)3.0%
Posterior P(D|+)26.9%
Speed
Step 1 of 4 • Speed 1.00x
Markov chain
Initial state
v0 = [0.60, 0.20, 0.20]
Transition matrix + state distribution
From \\ ToSunnyCloudyRainy
Sunny0.700.200.10
Cloudy0.300.400.30
Rainy0.200.300.50
Sunnyv0 60.0% -> v1 52.0%
Cloudyv0 20.0% -> v1 26.0%
Rainyv0 20.0% -> v1 22.0%
Cloudy is the remainder: 20%
Speed
Step 1 of 4 • Speed 1.00x
Naive Bayes
Prior
P(Spam) = 0.4
P(Ham) = 0.6
Naive Bayes likelihood table
FeatureP(feature|Spam)P(feature|Ham)
win0.700.10
free0.600.05
Spam posterior98.2%
Ham posterior1.8%
Speed
Step 1 of 4 • Speed 1.00x

Jeffrey and Dempster-Shafer

Soft evidence and belief fusion

Follow each term in Jeffrey updates and Dempster-Shafer combination.

Jeffrey update
Soft evidence
P'(E) = 0.70
P'(not E) = 0.30
Speed
Step 1 of 3 • Speed 1.00x
Dempster-Shafer
Mass assignments
m1(A)=0.60 m1(B)=0.20 m1(A or B)=0.20
m2(A)=0.40 m2(B)=0.30 m2(A or B)=0.30
Remainder mass is assigned to A or B (ignorance).
Speed
Step 1 of 3 • Speed 1.00x

Probability and Logic

Naive Bayes, Bayesian belief networks, and FOL to 2nd-order transformations

Naive Bayes problems
Prior
P(Spam)=0.40
P(Ham)=0.60
Speed
Step 1 of 3 • Speed 1.00x
Bayesian belief network
Structure
Cloudy -> Rain
Cloudy -> Sprinkler
Rain, Sprinkler -> WetGrass
CloudyRainSprinklerWetGrass
ConditionP(Rain=T)P(Sprinkler=T)
Cloudy=T0.800.10
Cloudy=F0.200.50
Nodes: Cloudy, Rain, Sprinkler, WetGrass. Evidence enters at WetGrass and propagates upward by inference.
Speed
Step 1 of 4 • Speed 1.00x
FOL to second-order
Natural language
All students love AI
Use FOL for object-level predicates, then show second-order form when quantifying over predicates/relations.
Speed
Step 1 of 3 • Speed 1.00x
Open source references available in the workspace: alg0.dev, AlgoFlow, algorithm-visualizer, and maze-solver visualizer. This lab is implemented as custom React components so the steps match your syllabus.

Step-by-step solve plans

Clear visual plans for each problem type

Search

How to solve a search problem

Visual plan

Use this when the question asks for the best path, the shortest route, or a node expansion order.

214225422Ah=8Bh=6Ch=5Dh=4Eh=3Fh=2Gh=0
Visual solve flow
1
step 1

Write the initial state, goal test, legal actions, and path cost.

2
step 2

Choose the algorithm family: BFS/DFS/IDS for uninformed, UCS for weighted cost, A* for informed search.

3
step 3

Track the frontier, explored set, parent links, g(n), and h(n) if the method needs it.

4
step 4

Expand the next node according to the algorithm rule and record every state change.

5
step 5

Stop at the goal, then reconstruct the path by following parent pointers backward.

  1. 1

    Write the initial state, goal test, legal actions, and path cost.

  2. 2

    Choose the algorithm family: BFS/DFS/IDS for uninformed, UCS for weighted cost, A* for informed search.

  3. 3

    Track the frontier, explored set, parent links, g(n), and h(n) if the method needs it.

  4. 4

    Expand the next node according to the algorithm rule and record every state change.

  5. 5

    Stop at the goal, then reconstruct the path by following parent pointers backward.

Exam verdict: If costs are uniform, BFS can be shortest-path optimal. If costs differ, UCS or A* is the safe answer.
Pseudocode

Search

How to solve a minimax / alpha-beta tree

Game tree plan

Use this when the problem is a game tree and the players are MAX and MIN.

Game tree (minimax + alpha-beta)
MAXMINMIN3527Minimax values propagate up; alpha-beta prunes when bound exceeded.
Visual solve flow
1
step 1

Label the root as MAX and alternate MAX/MIN levels down the tree.

2
step 2

Assign utilities at the leaves, then propagate values upward by minimax choice.

3
step 3

At MAX nodes, keep the largest child value; at MIN nodes, keep the smallest child value.

4
step 4

Carry alpha and beta bounds while traversing to prune branches that cannot affect the final result.

5
step 5

Return the move selected at the root and explain that pruning does not change the final minimax value.

  1. 1

    Label the root as MAX and alternate MAX/MIN levels down the tree.

  2. 2

    Assign utilities at the leaves, then propagate values upward by minimax choice.

  3. 3

    At MAX nodes, keep the largest child value; at MIN nodes, keep the smallest child value.

  4. 4

    Carry alpha and beta bounds while traversing to prune branches that cannot affect the final result.

  5. 5

    Return the move selected at the root and explain that pruning does not change the final minimax value.

Exam verdict: Alpha-beta is the same result as minimax, just with fewer expanded nodes when the move order is good.
Pseudocode

CSP

How to solve a CSP by hand

Constraint plan

Use this for map coloring, Sudoku, scheduling, N-Queens, and any assignment-style problem.

CSP assignment (example)
VariableDomainAssignment (step)
WA{Red, Green, Blue}Red (1)
NT{Red, Green, Blue}Green (2)
Q{Red, Green, Blue}Conflict with WA → backtrack
NSW{Red, Green, Blue}Green (3)
Visual solve flow
1
step 1

List the variables explicitly and define each domain.

2
step 2

Write the constraints atomically, not as one vague sentence.

3
step 3

Pick a variable ordering such as MRV or degree heuristic.

4
step 4

Try a value, then forward check or arc-consistency prune the neighbors.

5
step 5

Backtrack immediately on a conflict and continue until every variable is assigned consistently.

  1. 1

    List the variables explicitly and define each domain.

  2. 2

    Write the constraints atomically, not as one vague sentence.

  3. 3

    Pick a variable ordering such as MRV or degree heuristic.

  4. 4

    Try a value, then forward check or arc-consistency prune the neighbors.

  5. 5

    Backtrack immediately on a conflict and continue until every variable is assigned consistently.

Exam verdict: If the assignment is complete and all constraints are satisfied, you have the solution. The path itself does not matter.
Pseudocode

Logic

How to translate and reason in FOL

Translation plan

Use this when the task asks you to encode English statements or compare first-order and second-order logic.

Visual solve flow
1
step 1

Identify the objects, predicates, and relations in the sentence.

2
step 2

Decide where universal and existential quantifiers belong.

3
step 3

Translate each clause with the correct logical connectors and scope.

4
step 4

Check the formula against a small example model to catch quantifier mistakes.

5
step 5

Close with a short defense: FOL is enough when you only need objects and relations, not predicates over predicates.

  1. 1

    Identify the objects, predicates, and relations in the sentence.

  2. 2

    Decide where universal and existential quantifiers belong.

  3. 3

    Translate each clause with the correct logical connectors and scope.

  4. 4

    Check the formula against a small example model to catch quantifier mistakes.

  5. 5

    Close with a short defense: FOL is enough when you only need objects and relations, not predicates over predicates.

Exam verdict: Most exam mistakes come from wrong quantifier scope, so always test the sentence with a concrete example.
Pseudocode

Probability

How to solve a Bayes / Naive Bayes question

Bayes plan

Use this when the question asks for a posterior, classification result, or probabilistic update.

Visual solve flow
1
step 1

Write the prior probability and the evidence likelihood.

2
step 2

Apply Bayes' rule and, if needed, normalize with total probability.

3
step 3

For Naive Bayes, multiply the feature likelihoods under the conditional-independence assumption.

4
step 4

Compare the posterior probabilities for each class or hypothesis.

5
step 5

State the final answer with a one-line explanation of why the evidence shifts the belief.

  1. 1

    Write the prior probability and the evidence likelihood.

  2. 2

    Apply Bayes' rule and, if needed, normalize with total probability.

  3. 3

    For Naive Bayes, multiply the feature likelihoods under the conditional-independence assumption.

  4. 4

    Compare the posterior probabilities for each class or hypothesis.

  5. 5

    State the final answer with a one-line explanation of why the evidence shifts the belief.

Exam verdict: Bayes answers how belief changes after evidence; Naive Bayes is the fast classifier version of the same idea.
Pseudocode

Uncertainty

How to explain Jeffrey's rule and Dempster-Shafer

Soft-evidence plan

Use this when the question says the evidence is uncertain, incomplete, or partially trusted.

Visual solve flow
1
step 1

Check whether the evidence is certain or only partially trusted.

2
step 2

If the evidence is soft, apply Jeffrey's rule by updating the belief distribution proportionally.

3
step 3

If the question asks about ignorance or sets of hypotheses, use belief and plausibility instead of a single probability.

4
step 4

When combining sources, mention conflict mass and explain what happens when the sources disagree.

5
step 5

Finish with the exam-safe line: Bayes needs firm evidence, Jeffrey handles soft evidence, and D-S can represent ignorance explicitly.

  1. 1

    Check whether the evidence is certain or only partially trusted.

  2. 2

    If the evidence is soft, apply Jeffrey's rule by updating the belief distribution proportionally.

  3. 3

    If the question asks about ignorance or sets of hypotheses, use belief and plausibility instead of a single probability.

  4. 4

    When combining sources, mention conflict mass and explain what happens when the sources disagree.

  5. 5

    Finish with the exam-safe line: Bayes needs firm evidence, Jeffrey handles soft evidence, and D-S can represent ignorance explicitly.

Exam verdict: Use Dempster-Shafer when you need to show uncertainty about the evidence itself, not just uncertainty about the outcome.
Pseudocode

Exam checklist

How to present the answer cleanly

1. Identify the problem

Write the state, variables, evidence, or utility structure before solving anything.

2. Show the working

List the frontier, assignments, quantifiers, or probabilities in the same order you reason about them.

3. Close with the verdict

End with the path, assignment, formula, or final defense statement that answers the question directly.