Can i get some good links /tutorials on tree rotation algorithms.
Not exactly for balancing the tree.I need it just to have a feel on rotations.
This is a discussion on Tree rotation algorithms within the C Programming forums, part of the General Programming Boards category; Can i get some good links /tutorials on tree rotation algorithms. Not exactly for balancing the tree.I need it just ...
Can i get some good links /tutorials on tree rotation algorithms.
Not exactly for balancing the tree.I need it just to have a feel on rotations.
think how you would do this step by step. what pointers would you change? do you need to keep temp pointers?Code:A / \ B C becomes B \ A \ C
unless im missing something, thats about all there is to tree rotation. any algorithm would come from you deciding which way to rotate
More Details: SourceForge.net Repository - [clibutils] Contents of /src/c_rb.cCode:static void pvt_left_rotate(struct clib_rb_t *pTree, struct clib_rb_node_t *x){ struct clib_rb_node_t *y; y = x->right; x->right = y->left; if (y->left != rb_sentinel) y->left->parent = x; if (y != rb_sentinel) y->parent = x->parent; if (x->parent){ if (x == x->parent->left) x->parent->left = y; else x->parent->right = y; } else pTree->root = y; y->left = x; if (x != rb_sentinel) x->parent = y; } static void pvt_right_rotate(struct clib_rb_t *pTree, struct clib_rb_node_t *x) { struct clib_rb_node_t *y = x->left; x->left = y->right; if (y->right != rb_sentinel) y->right->parent = x; if (y != rb_sentinel) y->parent = x->parent; if (x->parent) { if (x == x->parent->right) x->parent->right = y; else x->parent->left = y; } else pTree->root = y; y->right = x; if (x != rb_sentinel) x->parent = y; }