public static void rightRotate(Node x) { Node y = x.getLeft(); x.setLeft (y.getRight ()); if (!y.getRight ().Equals (nil)) { y.getRight ().setParent (x); } y.setParent (x.getParent ()); if (x.getParent ().Equals (nil)) { root = y; } else if (x.Equals (x.getParent ().getRight ())) { x.getParent ().setRight (y); } else { x.getParent ().setLeft (y); } y.setRight (x); x.setParent (y); y.setSize (x.getSize ()); x.setSize (x.getRight ().getSize () + x.getLeft ().getSize () + 1); }
public static void printTree(Node start, int level, string side) { if (!start.Equals(nil)) { Console.WriteLine ("(" + start.getKey() + " - " + start.getColor() + " - " + side + " - s: " + start.getSize() + " - p: " + start.getPlayerNumber() + " [" + level + "])"); printTree (start.getLeft (), level + 1, "left"); printTree (start.getRight(), level + 1, "right"); } }