Breadth First Search and Depth First Search

后端 未结 11 1768
悲&欢浪女
悲&欢浪女 2020-12-24 02:46

Can anybody give a link for a simple explanation on BFS and DFS with its implementation?

11条回答
  •  被撕碎了的回忆
    2020-12-24 03:04

    Heres the idea in basics:

    get a new queue ...initalize it with the root node .... loop through the entire queue and keep removing an item from the queue and printing it out (or saving it etc) and check if the same item has any children , if so push them onto the queue and continue in the loop until you traverse the entire segment(graph)...

提交回复
热议问题