Lec 3
Lec 3
Lec 3
• Here, the algorithms have information on the goal state, which helps in more
efficient searching. This information is obtained by something called a heuristic.
In this section, we will discuss the following search algorithms.
1.Greedy Search
2.A* Tree Search
3.A* Graph Search
The minor spanning tree is produced by the DFS traversal of an unweighted graph.
1.Detecting a graph's cycle: A graph has a cycle if and only if a back edge is visible
during DFS. As a result, you may run DFS on the graph to look for rear edges.
2.Topological Sorting: Topological Sorting is mainly used to schedule jobs based
on the dependencies between them. In computer science, sorting arises in
instruction scheduling, ordering formula cell evaluation when recomputing
formula values in spreadsheets, logic synthesis, determining the order of
compilation tasks to perform in makefiles, data serialization, and resolving
symbols dependencies linkers.
3.To determine if a graph is bipartite: You can use either BFS or DFS to color a new
vertex opposite its parents when you first discover it. And check that each other
edge does not connect two vertices of the same color. A connected component's
first vertex can be either red or black.
4.Finding Strongly Connected Components in a Graph: A directed graph is strongly
connected if each vertex in the graph has a path to every other vertex.
Breadth First Search
• Breadth-first search is a graph traversal algorithm that starts
traversing the graph from the root node and explores all the
neighboring nodes.
• Then, it selects the nearest node and explores all the unexplored
nodes. While using BFS for traversal, any node in the graph can be
considered as the root node.
• BFS uses Queue Data Structure.
Algorithm
• Step 1: SET STATUS = 1 (ready state) for each node in G
• Step 2: Enqueue the starting node A and set its STATUS = 2 (waiting state)
• Step 3: Repeat Steps 4 and 5 until QUEUE is empty
• Step 4: Dequeue a node N. Process it and set its STATUS = 3 (processed
state).
• Step 5: Enqueue all the neighbours of N that are in the ready state (whose
STATUS = 1) and set
• their STATUS = 2
• (waiting state)
• [END OF LOOP]
• Step 6: EXIT
Applications of BFS algorithm