Re: counting BST nodes using iteration



CBFalconer said:

Richard Heathfield wrote:
CBFalconer said:
"subramanian100in@xxxxxxxxx, India" wrote:

... snip ...

I have written the following function to count the nodes in a BST
without using recursion. It uses iteration.

You don't need all that. A simple recursive implementation follows:

Doesn't meet the spec (which is "to count the nodes in a BST without
using recursion").

Why did you snip my final sentence, which covers that.

Because, to me, it looked like a hand-wave over the whole issue. "To
avoid recursion, use this recursive solution and then remove the
recursion" is not what I'd have called a good answer to the question.
Nevertheless, if you feel I have misrepresented you or been unfair to
you, I apologise. That was not my intent.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.