Snippets tagged tail recursion

  • sum the nodes in a (not-binary) tree using continuations

    you can easily find how to use continuations to iterate over a binary tree but what if the count of children for each node is not known at design time? It's not so obvious how to do this in order to get a tail-recursive method. This short snippet shows how to do this to sum the values of every leaf. The second part demonstrates a general approach for other operations than addition.

    26 people like this

    Posted: 10 years ago by Carsten K├Ânig

  • Factorial

    Factorial versus tail recursion

    4 people like this

    Posted: 8 years ago by Laco