Bagging Decision Trees Without NumPy

Asked at Pinterest · Coding & Leetcode-style Questions · Difficulty: Medium · Last asked Oct 28, 2026

Bagging (bootstrap aggregating) makes a classifier more stable: you train many copies of the same model, each on a resampled copy of the training set, and let them vote. You are given a small, complete decision-tree learner written in plain Python. Your job is to build the ensemble around it: draw the resampled training sets and combine the trees' predictions. Only the standard library is available (no NumPy), and every random draw comes from one seeded `random.Random`, so the result is fully reproducible.

Loading the problem…