Home > Back-end >  Questions about the rotation of the balanced binary tree algorithm
Questions about the rotation of the balanced binary tree algorithm

Time:02-24

Balanced binary tree you have just learnt rotation are spread on the Internet to see a lot of code under the pointer reference to the similar
//left left rotating
Void SingRotateLeft (TreeNode * & amp; K2)
{
TreeNode * k1.
K1=k2 - & gt; left;
K2 - & gt; Left=k1 - & gt; Right;
K1 - & gt; Right=k2.


K2 - & gt; Height=Max (height (k2 - & gt; Left), height (k2 - & gt; Right)) + 1;
K1 - & gt; Height=Max (height (k1 - & gt; Left), k2 - & gt; Height) + 1;

K2=k1;//this step change incoming pointer to his original left subtree
}
K2 subtree into balanced binary tree so that the root node of the subtree into k1 k2 node's parent still point to the ah k1, k2's parent who is it
  • Related