What is the training time complexity of building a Random Forest with B trees, N samples and M features?

Quick Overview

Derive the training time complexity of a random forest in terms of the number of trees, samples, features and features tried per split. Tests per-node split cost, how costs add up across levels and depth, and how presorting, histograms and depth limits change the total.

What is the training time complexity of building a Random Forest with B trees, N samples and M features?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

What is the training time complexity of building a Random Forest with $B$ trees, $N$ samples and $M$ features? ```hint Work one level at a time Find the cost of choosing a split at a single node, then look at what the nodes at one depth of the tree have in common. ``` ```hint Which features are searched How many features does a random forest node actually evaluate, compared with a plain CART tree? ``` ### What a Strong Answer Covers - The cost of finding the best split at one node, in terms of the node size and the number of candidate features. - How per-node costs add up across a level and across the depth of a tree, for balanced and degenerate trees. - The role of the per-split feature subset size, compared with searching all $M$ features. - How presorting or histogram binning changes the sorting term. - Practical factors: bootstrap sampling, depth limits, and how the number of trees enters the total cost and the wall-clock time. ### Follow-up Questions - What is the prediction time for one sample, and how do depth limits change it? - Why do histogram-based implementations scale better on large $N$, and what do they give up? - How does training cost change for extremely randomized trees, which pick split thresholds at random? - How does the memory footprint of a fully grown forest grow with $N$?

Overview: Derive the training time complexity of a random forest in terms of the number of trees, samples, features and features tried per split. Tests per-node split cost, how costs add up across levels and depth, and how presorting, histograms and depth limits change the total.

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

What is the training time complexity of building a Random Forest with BB trees, NN samples and MM features?

What a Strong Answer Covers Guidance

  • The cost of finding the best split at one node, in terms of the node size and the number of candidate features.
  • How per-node costs add up across a level and across the depth of a tree, for balanced and degenerate trees.
  • The role of the per-split feature subset size, compared with searching all MM features.
  • How presorting or histogram binning changes the sorting term.
  • Practical factors: bootstrap sampling, depth limits, and how the number of trees enters the total cost and the wall-clock time.

Follow-up Questions Guidance

  • What is the prediction time for one sample, and how do depth limits change it?
  • Why do histogram-based implementations scale better on large NN , and what do they give up?
  • How does training cost change for extremely randomized trees, which pick split thresholds at random?
  • How does the memory footprint of a fully grown forest grow with NN ?