# Implementation and Evaluation of Search Methods. Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack.

## Presentation on theme: "Implementation and Evaluation of Search Methods. Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack."— Presentation transcript:

Implementation and Evaluation of Search Methods

Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack. Call this node N. 3. Push children of node N onto the stack in right-to-left order (so they are popped in left-to-right order). 4. Repeat steps 2 and 3 until stack is empty or goal is reached. Simple Algorithm Depth-First Search

A General Algorithm

Implementation of different algorithms

Comparing Search Strategies Completeness – Will a solution be found if there is one? Optimality Will the optimal solution be found? Time Complexity Space Complexity

Breadth First Search Complete Finds shallowest goal may be optimal, may not Open list can be quite large O(b^d+1) space complexity Time is equally slow – O(b^d+1) time complexity

Depth First Search Not Complete – May get stuck on an infinite path Not Optimal – Unclear where the goal will be found Open list is relatively restricted O(b^m) space complexity Time is slow, perhaps slower than BFS O(b^m) time complexity

Uniform Cost Search Complete – Will find a solution if it exists at finite depth Optimal – Expansion order guarantees optimal solution Complexity difficult to pin down, O (b c/m)

Iterative Deepening Search Complete? Yes Optimal? Yes, if step cost = 1 db + (d-1)b^2 + (d-2)b^3 + … + (1)b^d BFS: b + b^2 + b^3 + … + b^d + b^d+1 – b

Bidirectional Search  Requires an explicit goal state  Simultaneously search forward from initial state and backwards from the goal state until the two meet  Concatenate the path from initial state to the inverse of the path from the goal state to form a complete solution  Use two queues to implement- for the halves Guarantees optimal solution Time complexity is O (b d/2 ) since the search only proceeds to half solution depth. Space complexity is also O (b d/2 ) as at least one of the searches has to be breadth first to find a common state

Bi-Directional Search Complete – If we use breadth first from both directions Optimal – With same caveats as breadth first Complexity better than breadth first, O(b^d/2) space complexity Time is also better – O(b^d/2) time complexity

Download ppt "Implementation and Evaluation of Search Methods. Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack."

Similar presentations