Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

AVL isn't complicated. Insert the node as you would in a binary tree. Do that recursively. Then, when you return from inserting, you check at each level if the height of the tree under the left and right children differ at most 1. If not, you perform a little shuffle of the nodes, update the levels, and return to the previous level. That's all. The proof that that works is a bit complicated, though.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: