Why is finding the globally optimal decision tree NP-hard?

Quick Overview

Asks why learning the globally optimal decision tree is computationally intractable while greedy methods such as CART are fast. Tests understanding of the size of the tree search space, interacting splits, reduction-based hardness proofs and what exact tree solvers can handle.

Why is finding the globally optimal decision tree NP-hard?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

Algorithms such as CART build a decision tree one split at a time. Here "optimal" means, for example, the smallest tree, or the tree with the fewest expected tests, that classifies the training data correctly. Why is finding the globally optimal decision tree NP-hard? ```hint A big search space is not a proof Counting the possible trees is a good start, but many problems with huge search spaces are still solvable in polynomial time. Think about what kind of argument actually establishes NP-hardness. ``` ```hint Try a tiny dataset Take the four points of XOR on two binary features and compute the information gain of each possible root split. ``` ### What a Strong Answer Covers - What "optimal" means (size, depth or expected number of tests on the training data) and the difference between NP-complete and NP-hard - The size of the space of trees, and why that size alone does not prove hardness - Why split choices interact, with a concrete case such as XOR where every greedy root split has zero gain - The reduction argument and the known result for binary decision trees - What this means in practice: greedy splitting with pruning, and exact solvers that only scale to shallow trees or small data ### Follow-up Questions - If optimal trees are NP-hard to find, why do greedy trees work so well in practice and inside ensembles? - Does a two-level lookahead fix the XOR problem? What about parity on k bits? - Why does a tree that is optimal on the training data not guarantee the best test accuracy? - How would you formulate depth-limited optimal tree learning as a mixed-integer program, and what limits its scale?

Overview: Asks why learning the globally optimal decision tree is computationally intractable while greedy methods such as CART are fast. Tests understanding of the size of the tree search space, interacting splits, reduction-based hardness proofs and what exact tree solvers can handle.

Nov 24, 2026
hardMachine Learning EngineerOtherMachine Learning
0
0

Algorithms such as CART build a decision tree one split at a time. Here "optimal" means, for example, the smallest tree, or the tree with the fewest expected tests, that classifies the training data correctly. Why is finding the globally optimal decision tree NP-hard?

What a Strong Answer Covers Guidance

  • What "optimal" means (size, depth or expected number of tests on the training data) and the difference between NP-complete and NP-hard
  • The size of the space of trees, and why that size alone does not prove hardness
  • Why split choices interact, with a concrete case such as XOR where every greedy root split has zero gain
  • The reduction argument and the known result for binary decision trees
  • What this means in practice: greedy splitting with pruning, and exact solvers that only scale to shallow trees or small data

Follow-up Questions Guidance

  • If optimal trees are NP-hard to find, why do greedy trees work so well in practice and inside ensembles?
  • Does a two-level lookahead fix the XOR problem? What about parity on k bits?
  • Why does a tree that is optimal on the training data not guarantee the best test accuracy?
  • How would you formulate depth-limited optimal tree learning as a mixed-integer program, and what limits its scale?