breadth first or depth first search

后端 未结 4 586
抹茶落季
抹茶落季 2021-02-04 17:09

I know how this algorithm works, but cant decide when to use which algorithm ?

Are there some guidelines, where one better perform than other or any considerations ?

4条回答
  •  没有蜡笔的小新
    2021-02-04 17:37

    Which method to use usually depends on application (ie. the reason why you have to search a graph) - for example topological sorting requires depth-first search whereas Ford-Fulkerson algorithm for finding maximum flow requires breadth-first search.

提交回复
热议问题