for complete tree tree at last level can have left child and no right
child , thus condition shd be somewhat like this...
if(node[right]==NULLnode[left]==NULL)
return true;
if(node[right]!=NULL) // if the node Rchild!=NULL then there shd be Lchild
present.
if(node[left]==NULL)
return FALSE;
On Wednesday, 4 July 2012 18:24:54 UTC+5:30, amrit harry wrote:
bool checkTree(Tree node)
{
if(node[right]==NULLnode[left]==NULL)
return true;
if(node[right]==NULLnode[left]!=NULL||node[left]==NULLnode[right]!=NULL)
return false;
else
return checkTree(node[right])checkTree(node[left]);
}
i think this algo can solve problem just traverse the node and keep eye on
that either a node have 2 childs or no child
On Wed, Jul 4, 2012 at 3:08 PM, Ashish Goel ashg...@gmail.com wrote:
i think checking full is easy, find height(0to h) and then check if level
h has 2^(h+1) nodes
how to check if it is complete..level order traversal? ensure that every
node has two children or left for the last one just before first leaf( till
you find the first leaf). Now on, every node should be a leaf.
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Wed, Jul 4, 2012 at 2:36 PM, Ashish Goel ashg...@gmail.com wrote:
ok, lets modify the problem to find if the tree is complete binary tree
The tree is a complete binary tree; that is, all levels of the tree,
except possibly the last one (deepest) are fully filled, and, if the last
level of the tree is not complete, the nodes of that level are filled from
left to right
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Wed, Jul 4, 2012 at 11:09 AM, atul anand atul.87fri...@gmail.comwrote:
http://www.geeksforgeeks.org/archives/5230
modify this to meet the requirnment.
On 7/4/12, Ashish Goel ashg...@gmail.com wrote:
WAP to find if a tree is balanced/fully balanced?
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the Google
Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
You received this message because you are subscribed to the Google
Groups Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Thanks Regards
Amritpal singh
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/XJ_ZvcBZv-8J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.