Notice
Recent Posts
Recent Comments
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
In Total
관리 메뉴

A Joyful AI Research Journey🌳😊

The differences between Depth-First Search (DFS) and Breadth-First Search (BFS) 본문

🌳Coursework Insights🪄✨/Adv Algorithms & Complexity

The differences between Depth-First Search (DFS) and Breadth-First Search (BFS)

yjyuwisely 2023. 10. 25. 15:25

https://www.quora.com/Are-the-majority-of-graph-algorithms-based-on-either-DFS-or-BFS

  1. Depth-First Search (DFS) - Left Diagram:
    • Traversal Path: It starts at the root node (the top-most node) and traverses through the left subtree as deep as possible before backtracking to traverse the right subtree.
    • Order of Node Exploration: The nodes are visited in the order 1, 2, 4, 6, 7, 5, 3.
    • Characteristic: DFS goes deep into a tree before backtracking. It dives down a branch as far as it can before moving to the next branch.
  2. Breadth-First Search (BFS) - Right Diagram:
    • Traversal Path: It starts at the root node and explores all neighboring nodes at the present depth before moving to nodes at the next depth level.
    • Order of Node Exploration: The nodes are visited in the order 1, 2, 3, 4, 5, 6, 7.
    • Characteristic: BFS explores all nodes at the current depth before proceeding to the next depth level. It's like exploring the tree level by level.

In summary, while DFS dives deep into a tree along a particular branch before backtracking, BFS explores nodes level by level. The image aptly depicts these traversal methods, making it easier to visualize and understand the differences between them.

728x90
반응형
Comments