What is the time complexity of training a balanced CART tree with N samples and D features?

Quick Overview

Asks for the training time complexity of a balanced CART decision tree in terms of sample count and feature count. Tests the per-node split search, why costs add up level by level, the effect of sorting and histogram binning, and how an unbalanced tree changes the bound.

What is the time complexity of training a balanced CART tree with N samples and D features?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

What is the time complexity of training a balanced CART tree with $N$ samples and $D$ features? Assume numeric features and a standard impurity criterion such as Gini or squared error. ```hint Count per level Look at all the nodes at one depth together. What do their sample counts add up to? ``` ```hint Where the sorting happens The answer depends on whether the samples are sorted once up front or again at every node. ``` ### What a Strong Answer Covers - The cost of finding the best split at a single node, separated into sorting and the threshold sweep - Why all the nodes at one depth together cost about one pass over the data per feature - How the total changes with presorting, re-sorting at every node, or histogram binning - What happens to the cost when the tree is far from balanced, and which settings bound it ### Follow-up Questions - What does it cost to predict one sample, and to train a random forest of $T$ trees that considers $m$ features per split? - Why does the incremental impurity update make the threshold sweep linear in the node size? - How does the histogram subtraction trick in gradient boosting libraries cut the work further? - How does the per-node cost change for a categorical feature with many levels?

Overview: Asks for the training time complexity of a balanced CART decision tree in terms of sample count and feature count. Tests the per-node split search, why costs add up level by level, the effect of sorting and histogram binning, and how an unbalanced tree changes the bound.

PracHub logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

What is the time complexity of training a balanced CART tree with NN samples and DD features?

Assume numeric features and a standard impurity criterion such as Gini or squared error.

What a Strong Answer Covers Guidance

  • The cost of finding the best split at a single node, separated into sorting and the threshold sweep
  • Why all the nodes at one depth together cost about one pass over the data per feature
  • How the total changes with presorting, re-sorting at every node, or histogram binning
  • What happens to the cost when the tree is far from balanced, and which settings bound it

Follow-up Questions Guidance

  • What does it cost to predict one sample, and to train a random forest of TT trees that considers mm features per split?
  • Why does the incremental impurity update make the threshold sweep linear in the node size?
  • How does the histogram subtraction trick in gradient boosting libraries cut the work further?
  • How does the per-node cost change for a categorical feature with many levels?