Balanced tree code is giving error

here is my code