Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Fa magassaga
- height :: (Tree a) -> Int
- height Empty = 0
- height (Node a _ b)
- | height a == height b = (height a) + 1
- | height b > 0 = (height b) + 1
- | height a > 0 = (height a) + 1
- //Fa ferdesege
- skew :: (Tree a) -> Int
- skew Empty = 0
- skew (Node a _ b) = (height a) - (height b)
- //Jobbra forgatas
- rightRot :: (Tree a) -> Tree a
- rightRot (Node (Node a x b) y c) = Node a x (Node b y c)
- //Balra forgatas
- leftRot :: (Tree a) -> Tree a
- leftRot (Node a x (Node b y c)) = Node (Node a x b) y c
- //Balra-jobbra forgatas
- leftRightRot :: (Tree a) -> Tree a
- leftRightRot (Node x z d) = rightRot(Node (leftRot x) z d)
- //Jobbra-balra forgatas
- rightLeftRot :: (Tree a) -> Tree a
- rightLeftRot (Node x z d) = leftRot(Node x z (rightRot d))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement