Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    @Victor: Thank you! Your hint to think about the parts of code that have to be run in "entering-the-function" situation and "returning-from-a-call" situation helped me understand intuitively. Also, thanks for the intermediate step where you unwound the tail-recursion; I've heard about it, but seeing it in action helped a lot! Commented Jan 22, 2010 at 14:05
  • 1
    That's a nice explanation... I figured the same in an difficult way.. But the above way of step-by-step breakdown has made it understand very simpler Commented Aug 16, 2010 at 4:44
  • 8
    I don't think traverse(node): if node != None do: traverse(node.left) print node.value traverse(node.right) endif is tail recursive Commented Aug 13, 2013 at 11:26
  • 2
    I agree with @JacksonTale. This is definitely not a clear case of tail recursion. Tail recursion requires a single recursive call. Recursive tree traversal is actually a typical example of non-tail-recursion. Commented Jan 11, 2016 at 22:25
  • Hi @Victor, That's the best article on this topic. Can you elaborate pre_order_traversal and post_order_traversal as well? ^_^ Commented Aug 23, 2018 at 6:50