Hi,

Is there any way of calculating the depth of a binary tree without
using *recursive way*.Also not using *log2-1* method.I am asking this
because Is there any way of doing this kind of operation with just
using stacks or quenes.In other words, is there a some kind of
compiler optimization just to avoid recursive call overhead?Here is
the recursive one (pseudo): Any comments?(Also optimization is not
important here.Is it just possible to implement an algorithm using one
stack or one quene,like traversal methods do?)

struct bnode{
   int data;
   bnode *l;
   bnode *r;

}

int height(bnode *n){
if (n == NULL) return 0;
else{
   int lheight = height(n->l);
   int rheight = height(n->r);
   return 1 + (lheight > rheight ? lheight : rheight);

}
}

Regards...


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to