r/learnprogramming • u/Temporary-Warthog250 • Apr 05 '22
Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them
Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.
Someone else who reads yours and does understand it, try to explain it to them to help them learn
1.6k
Upvotes
3
u/0xonox0 Apr 05 '22
Tree balancing is supposed to make tree operations (such as searching, inserting, or deleting) truly O(log(n)). You could have unbalanced trees (think just a linear tree where each node only has a left child) where the tree operations will just morph into a O(n) operation. If we balance the tree the height of the tree will decrease and since tree operations depend on the height, they will also be more efficient on balanced trees. There are various algorithms to make a tree balanced such as AVL trees to red black trees to multiway search trees; imo it's just better to watch a video on this than my trying to explain it to you in a reddit comment but the main goal of this algorithm is to make trees more balanced.
TLDR: Balanced trees lead to more efficient tree operations