Advertisement
xopsuei

BFS - Haskell

Nov 23rd, 2014
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- breadthFirst
  2. breadthFirst :: Tree a -> [a]
  3. breadthFirst Empty = []
  4. breadthFirst t = hack [t]
  5.  
  6. -- hack
  7. hack :: [Tree a] -> [a]
  8. hack [] = []
  9. hack ((Node a t1 t2):xs) = [a] ++ (hack (xs ++ [t1] ++ [t2]))
  10. hack ((Empty):xs) = hack xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement