Minimax Algorithm — AI Technical Interview Questions & Answers

Minimax Algorithm

Minimax Algorithm

  • Minimax: you maximise your score, the opponent minimises it. Recurse to leaves, back up values. Max node takes the max of children. Min node takes the min. Tic-tac-toe: +1 win, −1 loss, 0 draw. The first move is chosen from those backed-up numbers.
  • Depth explodes. That is why alpha-beta and depth limits exist. Trace a 2-ply tree on paper: three leaves 3, 5, 2 under a min, then a max above — say the backed-up value before coding.
  • Minimax Algorithm — output: min children: 3 2 / max chooses: 3. Same tree as the diagram.
MAX
       /   \
     MIN    MIN
     / \    / \
    3   5  2   9
     \ /    \ /
      3      2
        \  /
         3

Technical Interview Tip: Tiny 2-ply trace + backed-up value.

Code Examples for Minimax Algorithm

Example

# Minimax backup
left_min = min(3, 5)
right_min = min(2, 9)
print("min children:", left_min, right_min)
print("max chooses:", max(left_min, right_min))

Minimax Algorithm — output: min children: 3 2 / max chooses: 3. Same tree as the diagram.

How to Explain Minimax Algorithm to an Interviewer

Explain Minimax Algorithm as if you are teaching a junior — definition, then one example.

Max player / min opponent. Back up leaf scores.

What does the example print, and what does that prove?

Minimax Algorithm — output: min children: 3 2 / max chooses: 3

What mistake do freshers make with Minimax Algorithm?

exponential tree.