Weight balanced tree right rotation
procedure rrot( var t : tree ); var temp : tree; begin temp := t; t := t^.left; temp^.left := t^.right; t^.right := temp; {*** adjust weight ***} t^.weight := temp^.weight; temp^.weight := wt(temp^.left) + wt(temp^.right); end;
C
source (3414.rrot.c)
Pascal
source (3414.rrot.p)
©
Addison-Wesley
Publishing Co. Inc.