Binary Tree Preorder Traversal LeetCode (Tree Traversal - Preorder)

Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
   1
    \
     2
    /
   3
return [1,2,3].
Note: Recursive solution is trivial, could you do it iteratively?
This problem is an interesting tree traversal problem and is also popular in several forums including LeetCode and GeeksForGeeks A collection of hundreds of interview questions and solutions are available in our blog at Interview Question Solutions
Solution Source: Java

No comments:

Post a Comment