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,

Slides:



Advertisements
Similar presentations
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal.
Advertisements

Analysis of Algorithms Depth First Search. Graph A representation of set of objects Pairs of objects are connected Interconnected objects are called “vertices.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
Graph Searching CSE 373 Data Structures Lecture 20.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
G5BAIM Artificial Intelligence Methods Graham Kendall Blind Searches.
Blind Search1 Solving problems by searching Chapter 3.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.4) January, 14, 2009.
Search Strategies Reading: Russell’s Chapter 3 1.
Lets remember about Goal formulation, Problem formulation and Types of Problem. OBJECTIVE OF TODAY’S LECTURE Today we will discus how to find a solution.
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.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
Artificial Intelligence (CS 461D)
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
ALG0183 Algorithms & Data Structures Lecture 20 u unweighted breadth-first search 8/25/20091 ALG0183 Algorithms & Data Structures by Dr Andy Brooks Chapter.
Search in AI.
1 Trees Tree nomenclature Implementation strategies Traversals –Depth-first –Breadth-first Implementing binary trees Reading: L&C 9.1 – 9.7.
Review: Search problem formulation
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2004.
Graphs.
17-Jun-15 Searching in BeeperHunt (Mostly minor variations on old slides)
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2004.
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Using Search in Problem Solving
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2002.
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Search  Exhaustive/Blind Search Methods Depth First Search Breadth First Search  Heuristic Methods Hill Climbing Beam Search Best First Search…
1 Lecture 3 Uninformed Search
State-Space Searches. 2 State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
State-Space Searches.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Problem Solving and Search Andrea Danyluk September 11, 2013.
B-Tree. B-Trees a specialized multi-way tree designed especially for use on disk In a B-tree each node may contain a large number of keys. The number.
Tree Searching Breadth First Search Dept First Search.
1 Trees Tree nomenclature Implementation strategies Traversals –Depth-first –Breadth-first Implementing binary search trees.
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.
Problem-Solving by Searching Uninformed (Blind) Search Algorithms.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
A RTIFICIAL I NTELLIGENCE UNIT : 2 Search Techniques.
For Monday Read chapter 4, section 1 No homework..
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Algorithms April-May 2013 Dr. Youn-Hee Han The Project for the Establishing the Korea ㅡ Vietnam College of Technology in Bac Giang.
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.
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
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.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
COSC 2007 Data Structures II
Breadth-first and depth-first traversal CS1114
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Chapter 05 Introduction to Graph And Search Algorithms.
Source: David Lee Matuszek
Graph Searching CSIT 402 Data Structures II. 2 Graph Searching Methodology Depth-First Search (DFS) Depth-First Search (DFS) ›Searches down one path as.
Brute Force and Exhaustive Search Brute Force and Exhaustive Search Traveling Salesman Problem Knapsack Problem Assignment Problem Selection Sort and Bubble.
Graphs - II CS 2110, Spring Where did David leave that book? 2.
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.
Breadth First and Depth First
Iterative Deepening Search
Iterative Deepening Search
Depth-First Searches Introduction to AI.
Tree Searching.
Tree Searching.
Tree Searching.
Tree Searching.
Depth-First Searches.
Presentation transcript:

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, depending on the problem) For some problems, any goal node is acceptable ( N or J ); for other problems, you want a minimum-depth goal node, that is, a goal node nearest the root (only J ) LM N OP G Q H J IK FED BC A Goal nodes

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 LM N OP G Q H J IK FED BC A

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 LM N OP G Q H J IK FED BC A

How to do depth-first searching Put the root node on a stack; while (stack is not empty) { remove a node from the stack; if (node is a goal node) return success; put all children of node onto the stack; } return failure; At each step, the stack contains a path of nodes from the root The stack must be large enough to hold the longest possible path, that is, the maximum depth of search

How to do breadth-first searching Put the root node on a queue; while (queue is not empty) { remove a node from the queue; if (node is a goal node) return success; put all children of node onto the queue; } return failure; Just before starting to explore level n, the queue holds all the nodes at level n-1 In a typical tree, the number of nodes at each level increases exponentially with the depth Memory requirements may be infeasible When this method succeeds, it doesn’t give the path

Depth- vs. breadth-first searching When a breadth-first search succeeds, it finds a minimum- depth (nearest the root) goal node –A separate mechanism is needed to keep track of the path to the goal node When a depth-first search succeeds, the path to the goal node is on the stack –The found goal node is not necessarily minimum depth For a large tree, breadth-first search memory requirements may be excessive For a large tree, a depth-first search may take an excessively long time to find even a very nearby goal node How can we combine the advantages (and avoid the disadvantages) of these two search techniques?

Depth-limited searching Depth-first searches may be performed with a depth limit: boolean limitedDFS(Node node, int limit, int depth) { if (depth > limit) return failure; if (node is a goal node) return success; for each child of node { if (limitedDFS(child, limit, depth + 1)) return success; } return failure; } Since this method is basically DFS, if it succeeds then the path to a goal node is in the stack

Depth-first iterative deepening limit = 0; found = false; while (not found) { found = limitedDFS(root, limit, 0); limit = limit + 1; } This searches to depth 0 (root only), then if that fails it searches to depth 1, then depth 2, etc. If a goal node is found, it is a nearest node and the path to it is on the stack –Required stack size is limit of search depth (plus 1)

Time requirements for depth-first iterative deepening on binary tree Nodes at each level Nodes searched by DFS 1 +2 = 3 +4 = 7 +8 = = = = = 255 Nodes searched by iterative DFS 1 +3 = 4 +7 = = = = = = 502

Time requirements on tree with branching factor 4 Nodes at each level Nodes searched by DFS 1 +4 = = = = = = = Nodes searched by iterative DFS 1 +5 = = = = = = = 29124

Iterative deepening: summary When searching a binary tree to depth 7: –DFS requires searching 255 nodes –Iterative deepening requires searching 502 nodes –Iterative deepening takes only about twice as long When searching a tree with branching factor of 4 (each node may have four children): –DFS requires searching nodes –Iterative deepening requires searching nodes –Iterative deepening takes about 4/3 = 1.33 times as long The higher the branching factor, the lower the relative cost of iterative deepening depth first search

The End