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. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.