Algorithm Comparisons

Side-by-side breakdowns of algorithms that are commonly confused or compared on CS exams. Each entry covers core mechanics, complexity tradeoffs, and when to use which.

Machine Learning

Classifiers, regressors, and evaluation metrics — when to use each and what tradeoffs to expect.

9

KNN Classification vs. Naive Bayes

A deep-dive comparison of K-Nearest Neighbors vs. Naive Bayes. Understand lazy vs. eager learning, complexity tradeoffs, and exactly when to use each algorithm for exams.

View comparison

Decision Tree vs. Naive Bayes Classifier

Decision Trees split data using impurity measures to build explicit rules. Naive Bayes applies Bayes' Theorem assuming feature independence. Learn how they differ in assumptions, interpretability, data type fit, and exam traps.

View comparison

Decision Tree vs. Random Forest

A single Decision Tree is fast and interpretable but overfits easily. A Random Forest combines hundreds of trees to reduce variance at the cost of interpretability. Learn the tradeoffs, complexity, and exam pitfalls.

View comparison

KNN Classification vs. KNN Regression

KNN Classification and KNN Regression share the same distance-based neighbor lookup, but differ in how they produce a final answer. Learn the exact difference, metrics, and when to use each.

View comparison

KNN Regression vs. Linear Regression

KNN Regression memorizes training data and predicts locally. Linear Regression fits a global straight-line equation to the data. Learn the parametric vs. non-parametric distinction, complexity tradeoffs, and exam pitfalls.

View comparison

KNN Classification vs. K-Means Clustering

KNN and K-Means both use distances and the letter K, but they solve completely different problems. Learn the supervised vs. unsupervised distinction, complexity tradeoffs, and exam pitfalls.

View comparison

Simple Linear Regression vs. Multiple Linear Regression

Simple Linear Regression fits a line through one feature. Multiple Linear Regression fits a hyperplane through many. Learn the model equations, assumptions, $R^2$ interpretation, multicollinearity, and exam traps.

View comparison

Precision vs. Recall (and the F1 Tradeoff)

Precision and Recall measure different things from the confusion matrix and pull in opposite directions. Learn the formulas, the tradeoff, F1-score, and exactly when to prioritize each for CS exams.

View comparison

Random Forest vs. K-Nearest Neighbors (KNN)

Random Forest trains an ensemble of decision trees at training time. KNN memorizes data and does all computation at prediction time. Compare accuracy, speed, memory, feature handling, and exam pitfalls.

View comparison

Uninformed and informed search strategies — optimality, completeness, and complexity tradeoffs.

5

A* Search vs. Greedy Best-First Search

A* uses both path cost and heuristic to guarantee the optimal solution. Greedy Best-First only follows the heuristic and finds a solution fast — but not necessarily the best one. Learn the f(n) vs h(n) distinction, admissibility, and exam traps.

View comparison

A* Search vs. Uniform Cost Search (UCS)

UCS is optimal but explores blindly in all directions by cost. A* is also optimal but uses a heuristic to focus the search toward the goal. Learn why A* dominates UCS, when UCS is preferred, and the admissibility condition that links them.

View comparison

Breadth-First Search (BFS) vs. Depth-First Search (DFS)

BFS explores layer by layer using a queue. DFS dives deep using a stack. They have opposite memory footprints, different completeness guarantees, and completely different use cases. Master the tradeoffs here.

View comparison

Uniform Cost Search (UCS) vs. Breadth-First Search (BFS)

BFS finds the shortest path by number of edges. UCS finds the shortest path by total edge cost. When all edges cost the same, they are identical. Learn exactly when they differ, the g(n) priority distinction, and exam traps.

View comparison

Greedy Best-First Search vs. Uniform Cost Search (UCS)

Greedy search rushes toward the goal using only a heuristic estimate — it's fast but can find a suboptimal path or get stuck. UCS ignores the goal entirely and expands by actual cost — it's slower but always finds the cheapest solution. Learn when each is appropriate and why neither is A*.

View comparison

Missing a comparison? Request one