/ ** Return the max of 2 branches (recursively!) *

public int getMaxHeight ()

(

if (isLeaf ()) / / is a leaf, it stops

return 1;

int hd = 0, hg = 0;

if (left! = null) = 1 + hg gauche.getMaxHeight ();

if (right! = null) = 1 + hd right.getMaxHeight ();

if (hd> hg) return hd;

return hg;

)

/ ** Returns the max of 2 branches (recursively!) *

public int getMaxHeight ()

(

int height = 1;

AVLNode node = this;

while (node.deseq! = 0) (

height + +;

if (node.deseq <0)

node = node.gauche;

else

node = node.right;

)

return height;

)

Obviously, it is invariant in all following instances AVLNode:

if left is zero, then:

if the right is zero, then:

deseq = 0, / / leaf

otherwise:

deseq> 0, / / right leaning tree

end if;

else if the right is zero, then :

deseq <0, / / left hanging tree

otherwise

deseq is any sign: two trees left and right non-zero,

the longest is indicated by the sign of deseq;

end if.