## DFS, BFS, Greedy and A-star Search AlgorithmsWhen searching for a value, following factors affect the quality of search: -
__Estimate of remaining distance__: Also called as Heuristic function**h**. -
__Cost of moving__: Denoted by**g**. This is applicable if all nodes do not have uniform cost for passing through them.
With the above definitions, search algorithms can be classified as: - Depth-first Search: Goes into full depth of one side, then other side, then other and so on.
- Breadth-first Search: Search as near to current node as possible.
- Greedy Search: Follows the least value of the heuristic function
**h**. - Uniform Cost Search: Follows the least value of
cost-from-start-to-node
**g**. Thus it behaves very similar to BFS. - A-star Search: Follows the least value of the
expression: cost-from-start-to-node + heuristic-cost-from-node-to-end
**(g+h)**.
:
For the below algorithms, passing a blue grid-box is 4 times costlier than a yellow one.Search Algorithms PlaygroundHeuristic value for any node is the Manhattan Distance between that node and the end-point. |

Got a thought to share or found a

bug in the code?

We'd love to hear from you:

Name: | |

Email: | (Your email is not shared with anybody) |

Comment: |

Facebook comments:

Site Owner: Sachin Goyal