The Boundary Forest Algorithm for Online Supervised and Unsupervised Learning