Skip to content

Instantly share code, notes, and snippets.

@hyone
Created August 3, 2012 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyone/3246701 to your computer and use it in GitHub Desktop.
Save hyone/3246701 to your computer and use it in GitHub Desktop.
Number of binary trees have N leaves
splites :: Int -> [(Int, Int)]
splites n = [ (x, n - x) | x <- [1..n-1] ]
count :: Int -> Int
count 1 = 1
count n = sum $ do
(i, j) <- splites n
return $ count i * count j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment