[comp.ai] Breadth-first search

tab@auc.UUCP (Terrence Brannon ) (12/04/89)

Is there any way of doing a breadth-first search recursively in C?

...!emory!auc!tab

hall@aplcen.apl.jhu.edu (Marty Hall) (12/05/89)

In article <32334@auc.UUCP> tab@auc.UUCP (4-Terrence Brannon ) writes:
>Is there any way of doing a breadth-first search recursively in C?

[Sorry to post, but mail to the author bounced]

I'm not quite sure why you want to do this recursively. It seems
to me that the most straight-forward approach is to make a queue,
where you put the children of the current node on the end of the
queue, then pop the next node off the front of the queue, etc.
The root node would be the initial element of the queue, of course.
You could make your top-level function recursive, but it seems to
me that you would pass the entire queue every time, so I don't see
that the recursion buys you anything. I guess my point is that
this doesn't seem like a fundamentally recursive process, the way
a depth-first search would be.

Hope that helps; perhaps I am misunderstanding your question?

				- Marty Hall
------------------------------------------------------
hall@aplcen.apl.jhu.edu    Artificial Intelligence Lab
apl_aimh@jhunix.bitnet     AAI Corporation
..!uunet!aplcen!hall       PO Box 126
(301) 683-6455             Hunt Valley, MD 21030

douglas@ms.uky.edu (John Douglas Turner) (12/05/89)

Yes I have a non-recursive version in C.

			john....

-- 
John Douglas Turner		douglas@ms.uky.edu   or  douglas@UKMA.BITNET 
University of Kentucky			{rutgers,uunet}!ukma!douglas
902 Patterson Office Tower  			(606)-257-6824 
Lexington, Ky.  40502