Tuesday, July 15, 2014

[Leetcode] Tree Preorder, In-order and Postorder Traversal

Problem

Given a binary tree, return the preorder, in order and postorder traversal of its nodes' values.
Note: Recursive solution is trivial, could you do it iteratively ?

Algorithm

Recursive solution is easy. 
Iterative solution can be treated in a same format.

Code



No comments:

Post a Comment