How to check if a tree is balanced or not in Java? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 16

How to check if a tree is balanced or not in Java?

1st Dec 2017, 9:21 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
8 ответов
+ 4
Use a scale
1st Dec 2017, 4:24 PM
Luis M Castro
Luis M Castro - avatar
+ 3
Another way is by using an AVL tree. This is a type of binary search tree that keeps itself balanced between insertions and deletions.
2nd Dec 2017, 1:08 AM
Ashton Durrant
Ashton Durrant - avatar
+ 2
there are various technique to implement tree you have to check following 1) Left subtree of T is balanced 2) Right subtree of T is balanced 3) The difference between heights of left subtree and right subtree is not more than 1.
3rd Dec 2017, 4:49 AM
Devendra Kumar
Devendra Kumar - avatar
+ 2
I needed a cashier in Java 1-number of items 2-price for each item 3-discount (1%->10%) error handling for more or less than 1->10 (zero is okay) 4-show total
5th Dec 2017, 3:44 AM
ammr
+ 2
I needed a cashier in Java 1-number of items 2-price for each item 3-discount (1%->10%) error handling for more or less than 1->10 (zero is okay) 4-show total
5th Dec 2017, 3:44 AM
ammr
+ 2
Can we use same binary tree for Mlm softwares desighn
8th Dec 2017, 10:49 AM
Sreejesh sreenivasan
Sreejesh sreenivasan - avatar
+ 2
I am not able to do the earning report using matching in binary tree
8th Dec 2017, 10:52 AM
Sreejesh sreenivasan
Sreejesh sreenivasan - avatar
+ 1
just by finding our the depth of the leaves. if all the leaves have the same depth then it's balanced. you need not check all the leaves if you're implementing a specific type of tree. binary or a binary search tree or an avl tree. ex - the avl tree is designed in such a way that all the leaves are at the same depth. it's always balanced.
8th Dec 2017, 7:02 AM
Ashray Aman
Ashray Aman - avatar