# Re: counting BST nodes using iteration

*From*: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>*Date*: Mon, 26 Mar 2007 09:39:37 +0000

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.

.

**Follow-Ups**:**Re: counting BST nodes using iteration***From:*CBFalconer

**References**:**counting BST nodes using iteration***From:*subramanian100in@xxxxxxxxx, India

**Re: counting BST nodes using iteration***From:*Ben Pfaff

**Re: counting BST nodes using iteration***From:*subramanian100in@xxxxxxxxx, India

**Re: counting BST nodes using iteration***From:*CBFalconer

**Re: counting BST nodes using iteration***From:*Richard Heathfield

**Re: counting BST nodes using iteration***From:*CBFalconer

- Prev by Date:
**want help in minimum vertex cover program** - Next by Date:
**counting subsets of S so that sum(S_n) = N** - Previous by thread:
**Re: counting BST nodes using iteration** - Next by thread:
**Re: counting BST nodes using iteration** - Index(es):