Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. insertAVLTree_ :: a (LH a) -> LH a | Eq, Ord a
  2. insertAVLTree_ e (Leaf) = (Node 0 e Leaf Leaf)
  3. insertAVLTree_ e (Node d x left right)
  4. | e <= x    = repair1 (Node d x (insertAVLTree_ e left) right)
  5. with repair1 newt =: (Node _ _ newl =: (Node _ r _ _) _)
  6.         | depth newl - depth right <> 2 = newt
  7.         | e < r = rotateR newt
  8.         | otherwise = rotateRL newt
  9. | otherwise = repair2 (Node d x left (insertAVLTree_ e right))
  10. with repair2 newt =: (Node _ _ _ newr =: (Node _ r _ _))
  11.         | depth newr - depth left <> 2 = newt
  12.         | e > r = rotateL newt
  13.         | otherwise = rotateLR newt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement