breadth-vs-depth

Quick‌ ‌Overview‌ ‌of‌ ‌Depth-First‌ ‌Search‌ ‌and‌ Breadth‌ ‌First‌ ‌Search‌

How Does Depth-First Search Work?

Depth-first search is a classic algorithm that finds the shortest path from the initial node to the terminal node.

Depth-first search is a classic graph-searching algorithm that, in its most basic form, visits nodes in a tree pattern. It starts at the root and explores its left subtree by depth first, then does the same with its right subtree. The search terminates if there are no unexplored nodes. The algorithm is said to have found a solution if it reaches an unreachable node or leaves all nodes explored.

Some Issues with Depth-First Search

Depth-first search is a method of finding the shortest path to the target node in a tree or graph. 

This type of search can help find the shortest path, but it also has some major side effects that are often overlooked. For example, this algorithm does not take into account heuristic information about each node and might get stuck on an unsuitable node. Additionally, it will always take the same path on its way back to the root node, which can be inefficient if there are many paths with similar lengths.

How does Breadth First Search work?

What is BFS?

Breadth First Search is a search algorithm that systematically explores all the immediate, level-1, child nodes of the current node before going deeper into the tree.

Breadth First Search is a very simple search algorithm. It starts at the starting node and searches all its child nodes. If it encounters any that have not been examined yet, it will do so before returning to explore any child nodes of those that have been searched. It continues this process until all nodes are exhausted or until a stopping criterion has been met.

Breadth First Search vs Dijsktra’s algorithm in a directed graph scenario?

Dijkstra’s algorithm is a graph search algorithm used to find the shortest path between two vertices in a graph. The algorithm is used for solving the single-source shortest-path problem (sometimes called the minimum cost flow problem) which consists of finding a path from one vertex, called the source, to all other vertices in the graph while minimizing total cost

Breadth First Search is an algorithm that iteratively expands promising nodes until some goal node or nodes are found.

Dijkstra’s algorithm vs BFS in a directed graph scenario

Dijkstra’s algorithm is a graph traversal algorithm used for finding the shortest path between nodes in a graph. It finds the shortest path by exploring the graph linearly, weighted by edge lengths. The breadth first search (BFS) is a general search algorithm that explores all possible paths between two vertices in a graph and can be used to find the shortest routes.

In an unweighted directed graph scenario, Dijkstra’s algorithm takes O(E+V) time where E refers to the number of edges and V refers to the number of vertices. In contrast, BFS takes O(E*H) where H refers to the number of edges.