Search algorithms (Maze Problem)

Preview:

Citation preview

Uninformed Informed

Breadth-First

Depth-First

Dijkstra

Bidirectional

Best-First

A*

function findPath(Node start_position, Node goal)add start_position to DataStructurewhile the DataStructure is not emptyChoose a node off the DataStructure, call it "item" Mark item as visited // make sure we don't search it againif “item” is the goal node, end the searchElse generate the 4 successors to itemset the parent of each successor to "item" // this is so we can backtrack our final solution for each successor Add it to the DataStructure // So we can search this nodeendendif we have a goal node, look at its ancestry to find the path (node->parent->parent->parent..., etc) if not, the queue was empty and we didn't find a path :^\end

Uninformed Search

Breadth-First

Queue DataStructure

Pop a node of a queue (FIFO)

Bidirectional

2 X BFS

=

Depth-First

Stack DataStructure

Pop a node of a Stack (LIFO)

Dijkstra

List DataStructurePriority Queue

Node with Minimum cost

Dijkstra = BFS ?

Informed Search

Best-First (Greedy)

List DataStructure

Node with Minimum Heuristic

Wouldn’t it be nice To

combine the best ofDijkstra and Greedy

A*

List DataStructure

Node with Minimum F(n)F(n) = g(n) + h(n)

Recommended