Posts

Showing posts from May, 2020

AVL

Image
Introduction Hello there, in the previous post I've talked about Binary Search Tree before. Some of you might've encountered a situation where when you input the first data with extreme value (too big or too small), the following leaves/nodes just get overweight at one side, probably looking like this. 100 /  50    /  \    45  60      /              30                 Actually, there's nothing wrong with it. But since one invented an innovation towards this, here we are, a self-balancing binary tree : AVL tree. Technically speaking, AVL tree is an self-balancing binary tree in which the difference of depth between left and right subtree cannot be more than one. How does it work So basically, everytime when we input a data, we check on the balance between the right and left sub trees, and perform rotation accordingly to realign [reba...