kd-tree homework for Princeton's online algorithm course