Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #1499 > unrolled thread

binary tree

Started bybob <bob@coolfone.comze.com>
First post2012-04-25 15:01 -0700
Last post2012-04-26 11:22 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.programming


Contents

  binary tree bob <bob@coolfone.comze.com> - 2012-04-25 15:01 -0700
    Re: binary tree Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-04-26 11:22 -0700

#1499 — binary tree

Frombob <bob@coolfone.comze.com>
Date2012-04-25 15:01 -0700
Subjectbinary tree
Message-ID<12099790.990.1335391297767.JavaMail.geo-discussion-forums@ynll26>
What is the best way to iteratively traverse a binary tree?

[toc] | [next] | [standalone]


#1501

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2012-04-26 11:22 -0700
Message-ID<3ogmr.20265$FQ1.15042@newsfe12.iad>
In reply to#1499
On 4/25/12 3:01 PM, bob wrote:
> What is the best way to iteratively traverse a binary tree?
It depends on the data structure used, how why your iterating it, size 
of the tree, etc...

I've seen tree implementations that keep a "next" link in the node 
structure, so you can traverse it just like a linked list.

Otherwise, you just follow the simple tree-traversal iteration 
algorithm, which I could derive right now, but I'm too busy :-) 
Basically, go as far left as you can, then "find the next node", which 
involves going right once and left as far as you can again, or up if you 
can't go right. Repeat until complete.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web