From: Glen Holcomb Date: 2008-06-12T23:47:18+09:00 Subject: Re: Basic Tree Data Structure ------=_Part_42366_14607793.1213282060831 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thu, Jun 12, 2008 at 8:00 AM, Dustin Barker < dustin.barker@agilepartners.com> wrote: > Hi Justin, > > If the tree is ordered, you could provide access the nth node by > implementing the [] operator. So for Child 1, could be: > > subtree = tree[0] > subtree.each { |x| put x } > > -Dustin > > > On Jun 11, 2008, at 5:08 PM, Justin To wrote: > > How would I traverse only one portion of the tree? For instance, only >> Child 1 and not Child 2? >> >> So I want to see: >> >> => "Child 1" >> => "Grandchild 1.1" >> => "Great Grand Child 1.1.1" >> => "Grandchild 1.2" >> => "Great Grand Child 1.2.1" >> >> >> Thanks!! >> -- >> Posted via http://www.ruby-forum.com/. >> >> > > You want to implement a depth first search. Poke around on google a bit and you should find plenty of information. -- "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can't hear a word you're saying." -Greg Graffin (Bad Religion) ------=_Part_42366_14607793.1213282060831--