2

I know about Breadth First Search and Depth First Search. I read this page, and also on SO, I found this question and this question too.

What I wanna know is some practical scenerio where I would use depth first over breadth search. Though I third question link I provided is kinda similar, my question is more geared toward t-sql and SQL Server 2008/2012 performance.

Also, if I use one over other can anyone show me an example how much (worst case scenario) performance impact can I have? Say, if I adopt a dfs, and I have 50 children in first node, and I am searching for 2nd node, the dfs would be about 50 times slow from what I can think, because it would first have to transverse 50 children then it will come to second node. Is this so or not? I mean is it just like this direct relation btw the performance or otherwise?

Lastly, to repeat my question again, although it may (most likely will be) application and requirement specific, I would like to know some practical scenario where I would use one over the other, and what might be the performance cost of choosing one over the other? Also, I am am maintain a category catalog what should I choose? Say, I am maintaining a books category catalog something like : science => physics => astronomy and so on, which one would be the best? dfs or bfs?

Community
  • 1
  • 1
Razort4x
  • 3,296
  • 10
  • 50
  • 88

1 Answers1

0

You pretty much answered your own question. Depending on the data, use the search method most likely to visit the desired node first.

Dan Pichelman
  • 2,312
  • 2
  • 31
  • 42