The Trade Desk Interview Question

Explain how a Decision Tree works from first principles, and how I could implement one without using any library.