red-black trees raise some nodes and lower others to help balance the tree ensure that the characteristics of binary search tree are not violated recall that in binary search tree the left children of any node have key values less than the nodewhile its right children have key values greater than or equal to the node if the rotation didn' maintain valid binary search treeit wouldn' be of much usebecause the search algorithmas we saw in the preceding relies on the search-tree arrangement note that color rules and node color changes are used only to help decide when to perform rotation fiddling with the colors doesn' accomplish anything by itselfit' the rotation that' the heavy hitter color rules are like rules of thumb for building house (such as "exterior doors open inward")while rotations are like the hammering and sawing needed to actually build it simple rotations in experiment we tried rotations to the left and right those rotations were easy to visualize because they involved only three nodes let' clarify some aspects of this process what' rotatingthe term rotation can be little misleading the nodes themselves aren' rotatedit' the relationship between them that changes one node is chosen as the "topof the rotation if we're doing right rotationthis "topnode will move down and to the rightinto the position of its right child its left child will move up to take its place remember that the top node isn' the "centerof the rotation if we talk about car tirethe top node doesn' correspond to the axle or the hubcapit' more like the topmost part of the tire tread the rotation we described in experiment was performed with the root as the top nodebut of course any node can be the top node in rotationprovided it has the appropriate child mind the children you must be sure thatif you're doing right rotationthe top node has left child otherwisethere' nothing to rotate into the top spot similarlyif you're doing left rotationthe top node must have right child the weird crossover node rotations can be more complicated than the three-node example we've discussed so far click startand thenwith already at the rootinsert nodes with the following valuesin this order