Why is the maximum depth important in decision trees?

The maximum depth of a decision tree sets the number of levels or splits allowed in the tree. It matters because it controls the model’s complexity: a very deep tree may overfit by memorizing fine details of the data, while a shallow tree may underfit because it cannot represent complex patterns. Choosing a suitable depth therefore helps balance accuracy and the ability to generalize.