title: Splay tree rotation algorithm: Why use zig-zig and zig-zag instead of simpler rotations?
body: <p>I don't quite understand why the rotation in the splay tree data structure is taking into account not only the parent of the rating node, but also the grandparent (zig-zag and zig-zig operation). Why would the following not work:</p>
  
  <p>as we insert, for instance, a new node to the tree, we check whether we insert into the left or right subtree. If we insert into the left, we rotate the result RIGHT, and vice versa for right subtree. Recursively it would be sth like this</p>
  
  <pre><code>Tree insert(Tree root, Key k){
      if(k &lt; root.key){
          root.setLeft(insert(root.getLeft(), key);
          return rotateRight(root);
      }
      //vice versa for right subtree
  }
  </code></pre>
  
  <p>That should avoid the whole "splay" procedure, don't you think?</p>