Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- showTree :: Show a => AVLTree a -> String -> String
- showTree Leaf h = "-Leaf"
- showTree (Node val h Leaf Leaf) intro = "-" ++ show val
- showTree (Node val h l Leaf) intro =
- "-" ++ show val ++ "\n" ++
- intro ++ " |\n" ++
- intro ++ " `" ++ showTree l (intro ++ " ")
- showTree (Node val h Leaf r) intro =
- "-" ++ show val ++ "\n" ++
- intro ++ " |\n" ++
- intro ++ " `" ++ showTree r (intro ++ " ")
- showTree (Node val h l r) intro =
- "-" ++ show val ++ "\n" ++
- intro ++ " |\n" ++
- intro ++ " +" ++ showTree l (intro ++ " |") ++ "\n" ++
- intro ++ " |\n" ++
- intro ++ " `" ++ showTree r (intro ++ " ")
- instance Show a => Show (AVLTree a) where
- show tree = showTree tree ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement