Hi at all!This is my new post!I am preparing the examination of algorithms and data structures at the university! Would I need an opinion on an exercise for the final exam! Here is the text:Consider a binary search tree whose nodes are C structures defined by

[tag]

Code:struct node { int val; struct node*left; struct node *right; }[/tag]

and defined a nonrecursive method "lessthan" that receives an input tree and an integer, and returns the number of values in the tree less than the value specified market. Suppose that

is available a stack S (global variable) where can be insert or remove pointers to nodes

(an empty tree is represented by a pointer with a NULL value).

This is my solution:

[tag]

Code:int lessthan(struct nodo*r,int val){ if (r == NULL) return 0; int nvalm=0; Push(S,r); while ((r=Pop(S))) { if( r->val < val) ++nvalm; if( r->left != NULL) Push(S,r->left); if( r->right != NULL) Push(S,r->right); } return nvalm; }[/tag]

Thanks to all and sorry for my English