It is http://www.geeksforgeeks.org/avl-tree-set-1-insertion/ which is in the first post of this page. :) It is the same site I mentioned before (which is implemented in C). You may keep your iterative implementation but need to adjust the height inside your loop. However, you won't gain much from iterative because this type of problem would not require many run in the loop. Why? Because the number of recursion should not be more than the current tree height (which is log2 -- binary search tree).

PS: I tried it again, the order of setting node height could replace the recursive height adjustment. I am wrong about the site code is incorrect. :(

Edited by Taywin

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.