Alpha-Beta Pruning Theory Guide

Try the Alpha-Beta Pruning Solver →
Advanced14 min readLast Updated June 26, 2026
Prerequisites:Minimax Algorithm, Tree Traversal
Alpha-Beta PruningMinimax OptimizationGame TheoryArtificial IntelligenceAlpha CutoffBeta CutoffGame Tree

You already understand Alpha-Beta Pruning — you just don't know it yet. When you're playing chess and your opponent makes a move that immediately hands them your Queen, you don't sit there calculating every possible response. You stop. That line is dead. No follow-up can save it. Alpha-Beta Pruning is the algorithm that teaches a computer to do the same thing.

  • It is not a new algorithm: It is just Minimax with one small upgrade — it keeps track of two running numbers, α\alpha (alpha) and β\beta (beta), as it searches.
  • Those two numbers act as a kill switch: The moment they confirm a branch cannot change the final answer, the algorithm stops exploring it and moves on.

Same result as Minimax. Just smarter about what it bothers checking.

How to Trace Alpha-Beta Pruning by Hand

1

Label every level of the tree before writing a single number. The root node is always MAXMAX. The row below it is MINMIN, the row below that is MAXMAX, alternating all the way to the leaves. Write 'MAXMAX' and 'MINMIN' physically next to each row on your exam paper. If you skip this, you will inevitably apply the wrong logic at depth 3 and invalidate your entire trace.

2

Write your starting bounds at the root. Before touching any other node, label the root with α=\alpha = -\infty and β=+\beta = +\infty. These represent the worst-case starting guarantees — MAX could not be doing worse, MIN could not be doing worse. As you move deeper, pass these values down to each child. Bounds can only tighten as the search progresses. They never widen.

3

Traverse left-first using Depth-First Search. Always go to the leftmost unevaluated child first. Write the current α\alpha and β\beta next to each node as you pass them down — do not rely on memory. Your exam paper is your scratch space.

4

At a leaf node, return its value directly. No bounds, no comparisons. Read the number off the tree and pass it straight back up to the parent.

5

At a MAX node, update α\alpha — then check for a cutoff. If the returned value is greater than the current α\alpha, update α\alpha to that value. Then ask: is αβ\alpha \ge \beta? If yes — cross out every remaining child of this node immediately. This is a β\beta-cutoff. It means MIN already has a path that is better than anything this MAX node can now offer, so MIN will never come here.

6

At a MIN node, update β\beta — then check for a cutoff. If the returned value is less than the current β\beta, update β\beta to that value. Then ask: is αβ\alpha \ge \beta? If yes — cross out every remaining child of this node immediately. This is an α\alpha-cutoff. It means MAX already has a path that is better than anything this MIN node can now offer, so MAX will never come here.

7

Propagate the result up and repeat. A MAX node passes its final α\alpha up to its parent. A MIN node passes its final β\beta up to its parent. That returned value is then used by the parent to update its own α\alpha or β\beta — and the same cutoff check fires again. Keep going until the root receives its value. That number is the optimal game score.

The Pruning Condition

Prune if αβ\text{Prune if } \alpha \ge \beta

Breaking Down the Formula

  • α\alpha (Alpha) the best score MAX is guaranteed anywhere along the current path from the root to this node. It starts at -\infty — an absolute floor so low that the very first real value the search finds will automatically beat it and become the new α\alpha. It only ever increases, because a better guarantee for MAX always replaces a worse one.
  • β\beta (Beta) the best score MIN is guaranteed anywhere along the current path from the root to this node. It starts at ++\infty — an absolute ceiling so high that the very first real value the search finds will automatically beat it and become the new β\beta. It only ever decreases, because a better guarantee for MIN always replaces a worse one.
  • The Cutoff Rule when αβ\alpha \ge \beta, the floor has met or crossed the ceiling. MAX already holds a guarantee on another path that is at least as good as the best outcome MIN would ever allow here. No child of this node can improve the final decision — so the algorithm stops and crosses them out. The strategic read: the opponent will simply never let the game reach this branch.

Solved Example: Tracing a Beta Cutoff by Hand

Draw this tree on paper before reading the steps. The root is a MAX node with two children: Branch A (left) and Branch B (right). Branch A is a MIN node whose only child is a leaf with value 5. Branch B is a MIN node with two children — the first leaf has value 2, and the second leaf is hidden (we will never need to evaluate it). We always evaluate left to right. Initial bounds at the root: α=\alpha = -\infty, β=+\beta = +\infty.

Step 1: Evaluate Branch A (left first)

Descend into Branch A. It is a MIN node — it inherits α=\alpha = -\infty and β=+\beta = +\infty from the root. Its only child is the leaf value 5. MIN returns 5 upward. Back at the root MAX node: 5 is greater than the current guaranteed floor α=\alpha = -\infty, so we update. The guaranteed floor on this path is now α=5\alpha = 5.

Step 2: Move to Branch B

Descend into Branch B. It is a MIN node — it inherits the updated bounds from the root: α=5\alpha = 5, β=+\beta = +\infty. The guaranteed ceiling starts at ++\infty — an absolute ceiling so high that the first real value encountered will automatically beat it and become the new β\beta.

Step 3: Evaluate Branch B's first child

The first leaf of Branch B returns the value 2. MIN compares: is 2 lower than the current guaranteed ceiling β=+\beta = +\infty? Yes. The guaranteed ceiling tightens: β=2\beta = 2. Now check the cutoff condition: is αβ\alpha \ge \beta? That is: is 525 \ge 2?

Step 4: Beta Cutoff fires — prune the hidden leaf

Yes: 525 \ge 2. The guaranteed floor has met or crossed the guaranteed ceiling. Cross out Branch B's remaining child immediately — do not evaluate it. Here is the justification to write on your exam: MAX already holds a guaranteed floor of α=5\alpha = 5 from Branch A. MIN controls Branch B and has already found a move worth only 2, so the best MAX can ever receive from this branch is 2. Since 2<52 < 5, MAX will never choose Branch B regardless of what the hidden leaf contains. The hidden leaf is irrelevant by definition.

Step 5: Return the result to the root

Branch B's MIN node returns β=2\beta = 2 upward. The root MAX node compares: is 2 greater than the current guaranteed floor α=5\alpha = 5? No. α\alpha stays at 5. The root returns α=5\alpha = 5 as the optimal game value. The hidden leaf was never evaluated, and the answer is identical to what full Minimax would have returned.

See the Interactive Solver in Action

Now that you know how to trace it by hand, use the solver to verify your work instantly. Build your exact tree and watch the algorithm walk through every cutoff decision step by step.

Rules & Common Mistakes

  • Exam Trap: Use \ge Not >> — They Are Not The Same
    The pruning condition is αβ\alpha \ge \beta, not α>β\alpha > \beta. When α\alpha and β\beta are exactly equal, the branch is still dead — MAX cannot do better than what MIN has already capped the path at. If you use strict inequality, you will evaluate nodes that should be pruned and lose marks on any tree where equal values appear at the boundary. This comes up constantly in exam questions specifically because professors know students get it wrong.
  • Exam Trap: α\alpha and β\beta Are Passed Down, Not Shared Globally
    This is the most common source of cascading wrong values in a manual trace. α\alpha and β\beta are not global variables sitting on a whiteboard that every node reads from. Each node receives a copy of its parent's current bounds at the moment it is visited. When a sibling branch updates α\alpha at a MAX node, that updated value is passed down to the next child — it does not teleport back up to nodes you already evaluated. Trace the tree like a DFS call stack: each recursive call carries its own snapshot of the bounds.
  • The Update Rule: MAX Raises the Floor, MIN Lowers the Ceiling
    This is the rule to write at the top of your exam trace. At a MAX node: compare the returned value against α\alpha — if it is higher, update α\alpha. Then pass β\beta down to the next child completely unchanged. At a MIN node: compare the returned value against β\beta — if it is lower, update β\beta. Then pass α\alpha down completely unchanged. Both values travel together at every node. The difference is which one each node type is responsible for tightening.
  • Pro Tip: In Exams, Move Ordering Is Already Set For You
    Move ordering only affects *how many* branches get pruned — it never changes the final answer. In an exam question, the tree is given to you left-to-right and that order is fixed. Your job is not to reorder it; your job is to correctly identify every branch that gets cut given that order. If the best moves happen to be on the right side, you will prune less — that is intentional in harder exam questions designed to test whether you can trace a near-worst-case tree accurately.

Strengths, Weaknesses & When To Use It

When to use it:Use Alpha-Beta Pruning any time your exam question or implementation calls for Minimax — it is a strict upgrade, not an alternative. The only scenario where you would deliberately use plain Minimax instead is when a question explicitly asks you to demonstrate the unoptimized baseline, or when you need to count exactly how many nodes a full tree evaluation visits. In every real implementation context, Alpha-Beta is the default. There is no performance downside — worst case, it degrades gracefully back to standard Minimax behaviour.

Advantages

  • Doubles Effective Search Depth: In the best case — when stronger moves are evaluated first — Alpha-Beta only needs to evaluate O(bm/2)O(b^{m/2}) nodes instead of Minimax's O(bm)O(b^m). That is not a marginal gain. It means the algorithm can search twice as deep into the game tree in the exact same computation time. On a typical exam tree, you will not hit perfect best-case pruning, but you will always prune at least some branches — worst case, it costs you nothing.
  • Guaranteed Identical Answers: Every branch Alpha-Beta prunes is mathematically proven to be irrelevant to the root decision. This is not an approximation or a heuristic — it is an exact optimization. The answer at the root is always identical to what full Minimax would have returned.

Disadvantages

  • Move Ordering Determines Everything: Alpha-Beta's efficiency depends entirely on evaluating stronger moves first. In the worst case — when the weakest moves appear on the left — zero branches get pruned and the algorithm degrades to full O(bm)O(b^m) Minimax. All gains disappear. On an exam, the tree order is fixed for you, so your job is to trace correctly given that order — not to reorder the tree yourself.
  • Insufficient for Exponentially Complex Games: Even at best-case O(bm/2)O(b^{m/2}), the branching factor of games like Go (b250b \approx 250) makes deep exact search computationally impossible. When halving the exponent still leaves an astronomically large number, exact tree search hits a hard wall — which is why modern engines for these games moved beyond Alpha-Beta entirely to approaches like Monte Carlo Tree Search and neural network evaluation.

Alpha-Beta Pruning vs. Standard Minimax

Most students treat Alpha-Beta Pruning and Minimax as two separate algorithms competing for the same job. They are not. Alpha-Beta is Minimax — with one surgical addition: a mechanism that recognises when a branch cannot possibly affect the root decision and stops searching it. Everything else is identical. Same recursion. Same player logic. Same final answer. The only question is how many nodes each version has to visit to get there.

  • Node Evaluation: Minimax visits every single node in the tree — it has no mechanism to skip anything, regardless of what it has already found. Alpha-Beta tracks a running floor α\alpha and ceiling β\beta and stops expanding any subtree the moment αβ\alpha \ge \beta. Minimax is unconditional. Alpha-Beta is conditional.
  • Correctness Guarantee: Minimax derives its answer by evaluating every possible outcome, so its correctness is trivially guaranteed by exhaustion. Alpha-Beta skips entire subtrees yet returns the identical root value — because every pruned branch is mathematically proven unable to change the outcome. One is correct by brute force; the other is correct by proof.
  • Performance Profile: Minimax has fixed, predictable performance — always O(bm)O(b^m), regardless of tree shape or move order. Alpha-Beta has variable performance: O(bm/2)O(b^{m/2}) in the best case down to O(bm)O(b^m) in the worst. Minimax never wastes work, but it never saves any either. Alpha-Beta can save enormous amounts of work — but only if stronger moves appear early in the search.
  • Real-World Applicability: Minimax becomes computationally unusable in games with high branching factors because it cannot skip anything. Alpha-Beta's halved exponent at best-case ordering means it can search to twice the depth in the same time — for a chess engine at b=35b = 35, that is the difference between seeing 6 moves ahead and seeing 12. This is why every serious game-playing AI uses Alpha-Beta rather than raw Minimax.

Implementation Pseudocode

// alpha = guaranteed floor on this path — the best MAX can already secure from root to here
// beta  = guaranteed ceiling on this path — the best MIN can already secure from root to here
// Prune when alpha >= beta: the floor has met or crossed the ceiling — this branch is irrelevant

function alphaBeta(node, depth, alpha, beta, isMaximizing):

    // BASE CASE: Reached a leaf or the depth limit — return the node's utility value
    if depth == 0 or node is a terminal node:
        return node.value


    // ── MAX'S TURN ──────────────────────────────────────────────────────
    if isMaximizing:

        // Start at absolute floor — so low that the first real value will always beat it
        bestValue = -Infinity

        for each child in node.children:

            // Recurse: pass current floor and ceiling down to the child
            childValue = alphaBeta(child, depth - 1, alpha, beta, false)

            // max(a, b): returns whichever value is higher — raises bestValue if child is better
            bestValue = max(bestValue, childValue)

            // max(a, b): raises the guaranteed floor if bestValue exceeds the current alpha
            alpha = max(alpha, bestValue)

            // BETA CUTOFF: floor has met or crossed the ceiling
            // MIN already holds a ceiling (beta) lower than MAX's guaranteed floor (alpha)
            // MIN will never allow the game to reach this node — prune all remaining children
            if alpha >= beta:
                break

        return bestValue


    // ── MIN'S TURN ──────────────────────────────────────────────────────
    else:

        // Start at absolute ceiling — so high that the first real value will always beat it
        bestValue = +Infinity

        for each child in node.children:

            // Recurse: pass current floor and ceiling down to the child
            childValue = alphaBeta(child, depth - 1, alpha, beta, true)

            // min(a, b): returns whichever value is lower — drops bestValue if child is better
            bestValue = min(bestValue, childValue)

            // min(a, b): lowers the guaranteed ceiling if bestValue falls below the current beta
            beta = min(beta, bestValue)

            // ALPHA CUTOFF: floor has met or crossed the ceiling
            // MAX already holds a floor (alpha) higher than MIN's guaranteed ceiling (beta)
            // MAX will never choose this path — prune all remaining children
            if alpha >= beta:
                break

        return bestValue


// ── INITIAL CALL (always start with widest possible window) ──────────
// alphaBeta(rootNode, maxDepth, -Infinity, +Infinity, true)

Time & Space Complexity

ScenarioTime ComplexitySpace ComplexityNotes
Best Case (Perfect Ordering)O(bm/2)O(b^{m/2})O(m)O(m)Here bb = branching factor (children per node) and mm = maximum tree depth. When the strongest move is always evaluated first, Alpha-Beta can immediately prune the second child of every pair — halving the exponent from mm to m/2m/2. The practical result: the algorithm searches to twice the depth of standard Minimax in identical computation time. Space stays O(m)O(m) because Alpha-Beta uses depth-first search — it only stores the current path from root to the active node, never the entire tree. Memory scales with depth, not with total node count.
Worst Case (Reverse Ordering)O(bm)O(b^m)O(m)O(m)When the weakest moves are evaluated first, the α\alpha and β\beta bounds never tighten enough to trigger a cutoff — every node is visited before a better option is found. Zero branches are pruned. The algorithm degrades to identical performance as standard Minimax: O(bm)O(b^m). All efficiency gains vanish.
Average Case (Random Ordering)O(b3m/4)O(b^{3m/4})O(m)O(m)With random move ordering, Alpha-Beta prunes inconsistently — better than worst case but far short of optimal. The exponent lands around 3m/43m/4 in practice. On an exam, the tree order is fixed for you, so this is the performance profile most relevant to your trace — expect some pruning, but not the maximum possible.

Summary

Alpha-Beta Pruning does not change what Minimax computes — it changes how much work Minimax has to do. Every concept on this page reduces to that single idea. The α\alpha and β\beta bounds are bookkeeping tools that track what has already been guaranteed along the current path. The pruning condition αβ\alpha \ge \beta is just the moment the bookkeeping reveals that a branch is irrelevant. The DFS traversal, the cutoff names, the move ordering sensitivity — these all fall into place the moment that central mechanic clicks. If you can trace a game tree by hand, label every node with its correct α\alpha and β\beta values, identify exactly where each cutoff fires and why, and explain why the root value is identical to full Minimax — you have genuinely mastered this algorithm, not just memorised it. That is the difference between a student who can answer the question that was asked and one who can answer the question that wasn't.

Alpha-Beta Exam Questions Students Always Get Wrong

  • Will I get a different answer than Minimax if I prune branches? How do I prove I won't?

    You will get the identical answer — always, without exception. Here is the one-sentence proof you can write on an exam: every branch that Alpha-Beta prunes is one the opponent would never permit the game to reach, because a better option already exists for them elsewhere in the tree. A branch that can never be reached cannot influence the root value. If your examiner asks you to justify this, state it exactly that way: the pruned branches are strategically unreachable, therefore irrelevant, therefore safe to remove.

  • I keep mixing up Alpha Cutoff and Beta Cutoff. Which one fires where?

    Anchor it to who raises the floor and who lowers the ceiling. A Beta Cutoff fires at a MAX node: MAX keeps raising the guaranteed floor α\alpha until αβ\alpha \ge \beta. MIN already holds a ceiling lower than MAX's floor — MIN will never allow the game to reach this node. Prune the remaining children of that MAX node. An Alpha Cutoff fires at a MIN node: MIN keeps lowering the guaranteed ceiling β\beta until αβ\alpha \ge \beta. MAX already holds a floor higher than MIN's ceiling — MAX will never choose this path. Prune the remaining children of that MIN node. The memory trick: the cutoff is named after the bound that gets *overrun*. In a Beta Cutoff, α\alpha rises until it overruns β\beta. In an Alpha Cutoff, β\beta drops until α\alpha overruns it. Beta Cutoff — β\beta is the victim. Alpha Cutoff — α\alpha is the aggressor.

  • What happens on my exam if the tree is ordered badly — worst moves on the left?

    Nothing breaks — the answer is still correct. What changes is how much work you have to show. With reverse ordering, α\alpha and β\beta bounds stay wide for the entire traversal because every node you visit is worse than the previous one. No cutoff condition ever triggers. You end up evaluating every single node — exactly like standard Minimax — and your working will show no pruned branches at all. If an exam question gives you a tree with weak moves on the left and asks 'how many nodes does Alpha-Beta evaluate?', the answer may simply be: all of them. That is not an error. That is the worst case, and recognising it is the correct answer.

  • Do alpha and beta reset to -\infty and ++\infty at every new node I visit?

    No — and this is the mistake that causes entire exam traces to collapse. α\alpha and β\beta are inherited from the parent node at the moment of the recursive call. Each node receives a snapshot of the bounds that were current when its parent visited it. They do not reset. Think of it as a phone call: when the parent calls the child, it passes its current α\alpha and β\beta as arguments. The child works with those values and may tighten them further — but it starts from where the parent left off, never from scratch.

  • On an exam, what do I actually write when a cutoff fires?

    Three things, in this order. First, write the condition that triggered it: αβ\alpha \ge \beta with the actual numbers (e.g., 525 \ge 2). Second, name the cutoff type correctly: a Beta Cutoff fires at a MAX node, an Alpha Cutoff fires at a MIN node. Third, cross out or clearly mark the remaining unevaluated children with a note like 'pruned' or 'not evaluated'. Do not leave it ambiguous — examiners need to see that you know *why* those nodes are crossed out, not just that you stopped there. A crossed-out branch with no label gets no marks for the pruning step even if the final root value is correct.

Core University Curriculum

This algorithm and its manual calculation methods are foundational requirements in leading Computer Science and Software Engineering programs worldwide. You will find this topic heavily featured in the syllabi of these standard AI courses:

Explore Related Algorithms