Per wiki: In an AVL Tree, the heights of the two child subtrees of any node differ by at most one;
I am not getting this at all, I was going to post it yesterday before I went to sleep, but I figured I would wait & try to figure it out. I am totally stumped on this.
My AVL Tree code builds a tree that looks like this:
HERE
Would it be breaking the definition since (struct 8->right) height is 0, and (23->right->right) height is 2? (difference of 2). Or do we not count (struct 8->right) height, since it does not exist?
I used the code my professor provided, but I was thinking that 16 should be root of 8 & 42, 8 should be the root of 15 & 4, and 42 would be the root of 16 & 72.
I compared the code with other AVL Tree code (in C++), and everything matched up for the most part (the max of 2 numbers was different, but that's short code).



LinkBack URL
About LinkBacks



