Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void leftRotate(TreeNode x) {
- TreeNode y = x.right; //Bestimme y, um es zu tauschen
- x.right = y.left; // XrightPointer zeigt auf YleftPointer
- if (y.left != _nil) {
- y.left.p = x;
- }
- y.p = x.p;
- if (x.p == _nil) {
- _root = y;
- } else if (x == x.p.left) {
- x.p.left = y;
- } else {
- x.p.right = y;
- }
- y.left = x;
- x.p = y;
- }
- public void rightRotate(TreeNode x) {
- TreeNode y = x.left;
- x.left = y.right;
- if (y.right != _nil) {
- y.right.p = x;
- }
- y.p = x.p;
- if (x.p == _nil) {
- this._root = y;
- } else if (x == x.p.right) {
- x.p.right = y;
- } else {
- x.p.left = y;
- }
- y.right = x;
- x.p = y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement