Upstart Interview Question

Following is a coding question: coding for the decision tree from scratch. The interview will give some hints along the way. But still need to understand the algorithm itself.