Catalan numbers for triangulations gambler’s ruin binary…
[This article was first published on isomorphismes, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Catalan numbers for
- triangulations
- gambler’s ruin
- binary trees
- trees
…from the Flajolet/Sedgewick coursera analysis of algorithms
in R:
catalan <- function(n) { if(n
(This is slow above catalan(10)
though, so here’s a memoised version. Then if you want to run above catalan(250)
you’ll need to adjust options(expressions=5e3)
to something higher; otherwise the nesting of calls goes too deep.)
To leave a comment for the author, please follow the link and comment on their blog: isomorphismes.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.