title: Rebalancing an AVL Tree
body: <p>I have the following AVL tree:</p>
  
  <pre><code>                               10
                               /    \
                              5     12
                             / \   /  \
                            2  8   11  13
                          /  \ /\   
                          1  4 7 9
  </code></pre>
  
  <p>If I insert 3 then I get:</p>
  
  <pre><code>                               10
                               /    \
                              5     12
                             / \   /  \
                            2  8   11  13
                          /  \ /\   
                          1  4 7 9
                            /
                           3
  </code></pre>
  
  <p>If I calculate the Balance Factor for each node it seems that every BF is valid:
  (Node:BF) -> 10:1, 5:0, 2:-1, 1:0, 4:-1, 8:0, 7:0, 9:0, 3:0, 12:0, 11:0, 13:0
  But apparently this tree needs to be rebalanced. Where is there an invalid BF and then how would go about making the necessary rotations. </p>