Solved

DFS & BFS

Posted on 2002-04-30
4
1,838 Views
Last Modified: 2011-10-03
I need programs for depth first search and breadth first search (of graph) implemented in 'C' language.
should be runable code(main(){}).
0
Comment
Question by:bhombal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:snoegler
ID: 6979934
Search what? Files? B-Trees? etc.?
0
 
LVL 6

Accepted Solution

by:
snoegler earned 50 total points
ID: 6979981
The concept of depth-first:

void DF_search(what)
{
  for(each child in what;;child++)
  {
    if(child->hasChilds()) search(child);
  }

  for(each child in what;;child++)
  {
    if(!child->hasChilds()) doSomething();
  }
}

Vice versa, breadth first:
void BF_search(what)
{
  for(each child in what;;child++)
  {
    if(!child->hasChilds()) doSomething();
  }

  for(each child in what;;child++)
  {
    if(child->hasChilds()) search(child);
  }
}
0
 
LVL 11

Expert Comment

by:griessh
ID: 7122216
Dear bhombal

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "snoegler"

comment(s) as an answer.

If you think your question was not answered at all, you can explain here why you want to do this and post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/


PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7138129
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 147
How to convert MFC::CString to UTF8 wchar_t* 10 454
Microsoft C++ code failing in executable that worked 9 138
C++ statement T∗ begin(Vector<T>& x) 5 43
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question