NTU CSIE DSA 2014 Spring Homework 6, Balanced Trees