Question d’entretien chez Amazon

Write a function to tell whether a BST is balanced

Réponse à la question d'entretien

Utilisateur anonyme

5 déc. 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