Breadth First and Depth First

Slides:



Advertisements
Similar presentations
Ch 4. Heuristic Search 4.0 Introduction(Heuristic)
Advertisements

CSC411Artificial Intelligence 1 Chapter 3 Structures and Strategies For Space State Search Contents Graph Theory Strategies for Space State Search Using.
Tree Searching. Tree searches A tree search starts at the root and explores nodes from there, looking for a goal node (a node that satisfies certain conditions,
Artificial Intelligence (CS 461D)
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
State Space Search 2 Chapter 3 Three Algorithms. Backtracking Suppose We are searching depth-first No further progress is possible (i.e., we can only.
Toy Problem: Missionaries and Cannibals
Structures and Strategies for State Space Search
Using Search in Problem Solving
Using Search in Problem Solving
1 Structures and Strategies for State Space Search 3 3.0Introduction 3.1Graph Theory 3.2Strategies for State Space Search 3.3Using the State Space to Represent.
For Friday Finish chapter 3 Homework: –Chapter 3, exercise 6 –May be done in groups. –Clarification on part d: an “action” must be running the program.
Binary Trees Chapter 6.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
3.0 State Space Representation of Problems 3.1 Graphs 3.2 Formulating Search Problems 3.3 The 8-Puzzle as an example 3.4 State Space Representation using.
Tree Searching Breadth First Search Dept First Search.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
CS 415 – A.I. Slide Set 5. Chapter 3 Structures and Strategies for State Space Search – Predicate Calculus: provides a means of describing objects and.
Search exploring the consequences of possible actions.
Lecture 3: Uninformed Search
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
For Friday Read chapter 4, sections 1 and 2 Homework –Chapter 3, exercise 7 –May be done in groups.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further.
CSCI 4310 Lecture 2: Search. Search Techniques Search is Fundamental to Many AI Techniques.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Source: David Lee Matuszek
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
Review Graph Directed Graph Undirected Graph Sub-Graph Spanning Sub-Graph Degree of a Vertex Weighted Graph Elementary and Simple Path Link List Representation.
Artificial Intelligence Solving problems by searching.
Brute Force II.
Adversarial Search and Game-Playing
ARTIFICIAL INTELLIGENCE
Data Structures Graphs - Terminology
Csc 2720 Instructor: Zhuojun Duan
Graph Searching.
Introduction to Artificial Intelligence
i206: Lecture 13: Recursion, continued Trees
Data Structures and Database Applications Binary Trees in C#
Artificial Intelligence (CS 370D)
Breadth-First Searches
Analysis and design of algorithm
Spanning Trees Longin Jan Latecki Temple University based on slides by
SOLVING PROBLEMS BY SEARCHING
Problem Solving and Searching
Searching for Solutions
Breadth-First Searches
Graphs.
Trees CMSC 202, Version 5/02.
Problem Solving and Searching
Tree Searching.
CMSC 202 Trees.
Spanning Trees Longin Jan Latecki Temple University based on slides by
CSE (c) S. Tanimoto, 2001 Search-Introduction
COMP171 Depth-First Search.
Depth-First Search CSE 2011 Winter April 2019.
CSE (c) S. Tanimoto, 2002 State-Space Search
Tree Searching.
Tree Searching.
Tree Searching.
Spanning Trees Longin Jan Latecki Temple University based on slides by
UNINFORMED SEARCH -BFS -DFS -DFIS - Bidirectional
ARTIFICIAL INTELLIGENCE
CSE (c) S. Tanimoto, 2004 State-Space Search
Analysis and design of algorithm
Search Strategies CMPT 420 / CMPG 720.
Lecture 4: Tree Search Strategies
Problem Solving by Searching Search Methods :
Presentation transcript:

Breadth First and Depth First State Space Search: Breadth First and Depth First

Motivations Many problems can be viewed as reaching a goal state from a given starting point, e.g., the farmer-wolf-goat-cabbage problem. Often there is an underlying state space successor function to proceed from one state to the next. Search strategies are important methods to explore such a space to obtain the goal state.

Objectives Top down search Bottom up search Breadth first search Depth first search Compare breadth first and depth first

State space for tic-tac-toe game Represent a problem as a state space Nodes represent discrete states, e.g., configuration of game board. Arcs (links, edges) represent transition between states e.g., move in a game. Analyze the structure and complexity of problem and search procedures using graph theory.

Breadth-first searching A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away For example, after searching A, then B, then C, the search proceeds with D, E, F, G Node are explored in the order A B C D E F G H I J K L M N O P Q J will be found before N L M N O P G Q H J I K F E D B C A

Breadth-first search algorithm Nodes are lining up to be visited in open. closed keeps track of all the nodes visited already.

breadth-first algorithm A trace of breadth-first algorithm B is not the goal. Put his children onto the queue. Put him in closed. He is done. | | | Items between red bars are siblings. | | | | | | | | | | | | goal is reached or open is empty.

Progress at iteration 6 open contains the nodes whose children have not been looked at yet. The queue is also called the frontier of the search. closed contains the nodes that have been visited, i.e., nodes that have been opened or expanded. | | | | | | | | | | | | | | |

Breadth-first searching summary L M N O P G Q H J I K F E D B C A

Depth-first searching A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path For example, after searching A, then B, then D, the search backtracks and tries another path from B Node are explored in the order A B D E H L M N I O P C F G J K Q N will be found before J L M N O P G Q H J I K F E D B C A

The depth-first search algorithm This is the only difference between depth-first and breadth-first.

depth-first algorithm A trace of depth-first algorithm top of stack

Snap shot at iteration 6 frontier visited

Recursive depth-first search algorithm DFS(node v) { visit(v) for each child w of v, DFS(w) } Recursion uses a stack to store data for previous calls. The children nodes (w’s)are placed on the undeclared (implicit) stack. Breadth first uses a queue instead of a stack, no recursion. At any given time, the top of the stack contains only the node on a path from the root to a goal. The stack only needs to be large enough to hold the deepest search path. When a goal node is found, the path can be extracted from the stack as the recursion unwinds.

Search sequences of depth-first and breadth-first Breadth first: A, B, C, … Depth first: 1, 2, 3, … Insert fig 3.15

Comparing the ordering of search sequences Determine the order of nodes (states) to be examined Breadth-first search When a state is examined, all of its children are examined, one after another Explore the search space in a level-by-level fashion Depth-first search When a state is examined, all of its children and their descendants are examined before any of its siblings Go deeper into the search space where possible

Summary Graph representation State Space Search Nodes are problem solution states Arcs are steps in problem solving State Space Search Find a solution path from start state to goal state. Determine complexity of problem Many problems (TSP) have exponential complexity, impossible to search exhaustively Strategies to search large space need heuristic to reduce space and time complexity