Hi my name is Javier, I am Computer science major. I need help with Binary tree operations. I need some help writing a non-recursive c++ function that counts the number of leafs in a tree?? Thanks you

i think this code wil help Code: nodeptr stack[MAX_SIZE]; inorder(nodeptr node) { int i = 0; while(1) { for(;node;node = node -> left) add(node); // adding node to stack node = pop(); // pop from stack if(!node->rchild && !node->lchild) i++; node = node->rchild; } printf("no of leaf nodes = %d",i); } Basically it is the same as the iterative version of the inorder traversal