Amazon Interview Question

Write a function to tell whether a BST is balanced

Interview Answer

Anonymous

Dec 5, 2013

Traverse the tree in order. Since its a BST it will yield sorted order. Count the number of elements (lets say n) If root is the n/2th or n/2 + 1 th element , then it is balanced Otherwise not