How do inference latency and model memory footprint scale with the number of trees and tree depth?

Last updated 5 November 2026

  • Per-sample inference latency is O(B · d): one root-to-leaf walk of about d comparisons per tree. Deeper trees also cause more cache misses and branch mispredictions.

  • Memory is O(B · nodes per tree), with nodes up to 2^d but bounded by data. Fully grown trees have about N leaves, so models are roughly O(B · N) and can reach gigabytes.

  • Accuracy plateaus well before B is large, and min_samples_leaf or max_leaf_nodes shrink the model roughly proportionally.

  • https://medium.com/data-science-collective/a-comprehensive-guide-to-random-forests-8d840c902dd5
  • https://medium.com/gitconnected/random-forest-pruning-explained-12b024e703bc
  • https://mbrenndoerfer.com/writing/random-forest-ensemble-learning-bootstrap-sampling-feature-selection-classification-regression-guide
All Random Forests interview questions