datarekha

Alpha-Beta Pruning

Same minimax answer, fewer nodes touched. Track the best each side has guaranteed so far, and cut whole subtrees the parent will never pick.

9 min read Advanced GATE DA Lesson 102 of 122

What you'll learn

  • Alpha tracks MAX's best-guaranteed value along the path; beta tracks MIN's
  • Prune a node's remaining children when its outcome cannot affect the parent's choice
  • Pruning depends on left-to-right evaluation order — node ordering changes how much gets pruned
  • The root value is unchanged from plain minimax — alpha-beta is an efficiency, not an approximation

Before you start

Plain minimax visits every leaf. That feels wasteful — once you’ve found a decent line, why keep exploring branches the opponent will obviously block? Alpha-beta is that intuition turned into a precise rule. It returns the same minimax value while skipping subtrees that can no longer change the answer.

The savings can be huge. With perfectly ordered moves, alpha-beta explores about the square root of minimax’s nodes — turning a depth-d search with branching b from b^d into roughly b^(d/2). That square-root cut is what let classic chess engines search twice as deep in the same time, and the same prune-what-can’t-matter idea reappears in branch-and-bound optimisers. GATE will not test the asymptotics, but it will absolutely test whether you can hand-trace which branches survive.

Alpha and beta, in one sentence each

  • α (alpha) — the best (largest) value MAX is currently guaranteed along the path from the root. Starts at -infinity. Only MAX raises α.
  • β (beta) — the best (smallest) value MIN is currently guaranteed along the path from the root. Starts at +infinity. Only MIN lowers β.

At every node you carry the pair (α, β) inherited from the parent. The pruning rule is one line:

If at any point α >= β, stop exploring this node's remaining children — prune.

The intuition: if MAX has already secured at least α, and the current subtree can offer MIN no more than β <= α, then MAX’s parent will never choose this subtree — so finishing it is wasted work.

A small tree with one cut

MAX3MIN A3MIN B≤2382×prunedAfter MIN B sees 2, MAX’s α=3 already exceeds it → cut the rest.
The dashed leaf is never evaluated — MAX would refuse anything MIN B returns.

How GATE asks this

A reliable MCQ/MSQ pattern: a small game tree drawn with leaves labelled, plus a question like “which leaves are pruned under left-to-right alpha-beta?” or “what range of x at this leaf causes pruning?”. Sometimes it asks the root value (always identical to plain minimax) as a sanity check. This pattern appeared in both GATE DA 2024 and 2025.

Worked example — based on real GATE DA 2024

A MAX root has two children, MIN A (left) and MIN B (right). MIN A’s leaves: [3, 8]. MIN B’s leaves: [2, ?]. Evaluating left-to-right, what does alpha-beta do with MIN B’s second leaf?

Start at the root with α = -infinity, β = +infinity.

Visit MIN A with (α=-inf, β=+inf).

  • First leaf of A returns 3. MIN updates its best: β = min(+inf, 3) = 3. Check: α < β still, so keep going.
  • Second leaf of A returns 8. MIN updates: β = min(3, 8) = 3 (no change). No more children. MIN A’s value is 3.

Back at the root (MAX), update α = max(-inf, 3) = 3. Now (α=3, β=+inf).

Visit MIN B with (α=3, β=+inf).

  • First leaf of B returns 2. MIN updates: β = min(+inf, 2) = 2. Check the pruning condition: α (=3) >= β (=2). Prune.

MIN B cannot return more than 2, and MAX already has 3 in hand — MAX will never pick this branch. The second leaf of B never gets evaluated. MIN B’s value is reported as <= 2 (it does not matter what exactly).

Root value: max(3, anything <= 2) = 3. Identical to plain minimax, and we saved one leaf evaluation. On a real game tree those savings compound across many subtrees.

A useful framing: at a MIN node, prune when its running value drops to <= α (further children can only lower it more, and MAX already has α). At a MAX node, prune when its running value climbs to >= β (further children can only raise it, and MIN already has β).

Quick check

Quick check

0/6
Q1In the worked-example tree (MAX root over MIN A with leaves [3,8] and MIN B with leaves [2, x]), what is the value backed up to the root by alpha-beta?numerical answer — type a number
Q2Same tree, but now consider MIN B's first leaf has value x (the second is still hidden). For what range of x does NO pruning occur at MIN B?
Q3A MAX root has three MIN children. Left MIN's leaves: [5, 2, 7]. Middle MIN's first leaf is 1 (others unseen). Right MIN's leaves are unseen. Under left-to-right alpha-beta, what is the value of α at the root just before visiting the middle MIN?numerical answer — type a number
Q4Continuing: at the middle MIN with (α=2, β=+inf), its first leaf is 1. What does alpha-beta do next?
Q5Which statements about alpha-beta pruning are TRUE? (select all that apply)select all that apply
Q6A MAX root has two MIN children. Left MIN's leaves (left-to-right): [10, 4]. Right MIN's leaves (left-to-right): [3, 1]. What is the root value under alpha-beta, and how many of the four leaves are evaluated?

Practice this in an interview

All questions
What is pruning in decision trees and when would you use pre-pruning versus post-pruning?

Pruning removes splits that do not improve generalisation. Pre-pruning stops growth early via hyperparameters like max_depth or min_samples_leaf. Post-pruning (cost-complexity pruning) grows the full tree then collapses nodes whose removal does not hurt held-out accuracy enough.

Walk me through exactly how a decision tree chooses a split at each node.

At each node the algorithm iterates over every feature and every candidate threshold, scores each candidate split by the weighted impurity of the two child nodes, and selects the pair that gives the largest impurity reduction. It then recurses on each child until a stopping criterion is met.

Generate all subsets of a set — the power set — using backtracking.

At each step of a recursive walk through the input, you make a binary choice: include the current element or skip it. Recording the current path at every node of the recursion tree (not just the leaves) collects all 2^n subsets. A `start` index prevents duplicates by ensuring elements are only considered left-to-right.

Find all unique combinations of candidates that sum to a target, where each candidate may be used an unlimited number of times.

Use backtracking with a running total. At each step, try adding a candidate to the current path. If the total equals the target, record the path. If it exceeds the target, prune. Passing the same start index (not i+1) back into the recursion allows unlimited reuse of the same element.

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Explore further

Related lessons

Skip to content