Below you will find pages that utilize the taxonomy term “alpha beta pruning”
Posts
Minimax - alpha beta pruning
Normal pruning Imagine you are given the following problem: Find the depth of the the leaf closest to the root of a tree.
def smallest_depth(node, depth): if node is None: return depth - 1 a = smallest_depth(node.left, depth + 1) b = smallest_depth(node.right, depth + 1) return min(a, b) You could improve this a little bit by passing some information to your children:
def smallest_depth(node, smallest_sofar, depth): if node is None: return depth - 1 if depth >= smallest_sofar: return depth a = smallest_depth(node.