On Nov 20, 8:52=A0am, Todd Benson <caduce... / gmail.com> wrote: > On Thu, Nov 20, 2008 at 8:27 AM, Robert Klemme > > > > <shortcut... / googlemail.com> wrote: > > 2008/11/20 Hugh Sasse <h... / dmu.ac.uk>: > > >> On Thu, 20 Nov 2008, equinox wrote: > > >>> Yes I know the algorithm of doing BFS, however I can't see where a > >>> hash is a graph structure... > > > Well, isn't this (i.e. analyzing the problem) part of your assignment? > > This really looks like a homework assignment... > > >>> How do I visit the child here? Which ones are trees in the same level= ? > > >> In the Pastie the keys point at arrays of strings. =A0But in that exam= ple > >> all the strings correspond to keys, except for lonelygirl13 which look= s > >> like a typo for the key lonelygirls13. =A0Normally to make a tree with > >> hashes you'd use hashes of hashes [of hashes [...]]. =A0It seems to me > >> you can't do Breadth first until you've got some Depth to not do first= ! > > > Hugh, not necessarily. You just need to look at the Hash as a vertex > > collection. =A0I'm not going to say more... :-) > > > Kind regards > > > robert > > Definitely agree with robert here. =A0But the $database seems contrived. > > I would guess the powers that be want you to come up with a clever way > to check your nodes. =A0To be honest my first solution (that I thought > was clever) turned out to walk each node from left to right, but just > wasn't even close to bfs. =A0Your parent node, with this type of hash, > is probably supposed to be the first one, and then stack them from > there. > > Todd so I'll need a queue to do this? How do you create a queue in ruby?