what the issue with this , while doing inorder traversal check if left and
right both are null its ur leaf node else keep traversing.
If i couldn't understood ur problem , please explain again.
On Sat, Mar 16, 2013 at 7:44 PM, Megha Agrawal megha1...@iiitd.ac.inwrote:
Hello all,
Is it
Hello all,
Is it possible to get leaf nodes from inorder traversal of a binary
tree(not BST)?
--
Thank you
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
I don't think so. If I understand your problem well, I have a
counter-example
take for example -
Inorder Traversal - 1-2-3
this could mean a binary tree rooted at 2 with 2 leaf nodes 1 and 3
but this could also mean a binary tree rooted at 3 with 2 as its left child
which in-turn has 1 as its
Ambiguity lies in the heart of this question.
If you are given a tree and you want to look for leaf nodes you can
simply do an inorder traversa,
and check for leaf nodes.
Time complexity will be O(N) and space complexity will be O(log N).
void
getLeafNodes (node *root) {
if (! root)