© All Rights Reserved

0 views

© All Rights Reserved

- my transcript
- IS Notes
- Comparing Numbers
- Call for Paper
- A star algorithm
- An Enumeration of Certain Equivalence Classes of Directed Multigraphs Having 0 to 5 Nodes with Each Node Having 2 Incoming and 2 Outgoing Arcs
- Computer Science Booklet
- MCA 4th sem ADA lab mannual
- Assignment 2
- 4.4 Cube Roots
- Data Cube Technology
- gr12
- Data Mining-Graph Mining
- sipr
- Moddel Trans From at Ion as an Optimization Problem
- Algorithmic Graph Theory
- Mat Lab Problems
- Optimized AO* Algorithm for and-Or Graph Search
- 20121108 Quiz 6b Solutions
- Seminar Report on Low Density Parity Check codes

You are on page 1of 156

ARTIFICIAL

INTELLIGENCE

Lecture Set 05

Uninformed Search

By Engr. Ali Asghar Manjotho

Lecturer Department of Computer Systems Engineering

MUET Jamshoro

ali.manjotho@faculty.muet.edu.pk

ali.manjotho.ali@gmail.com

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Outlines

■ Uninformed Search

■ Breadth-First Search

■ Backward Breadth-First Search

■ Bi-Directional Breadth-First Search

■ Depth-First Search

■ Depth Limited Search

■ Depth-First Iterative Deeping Search (DFID)

■ Evaluating Search Algorithms

■ Uniform Cost Search

■ Repeated States

■ How to deal with repeated states?

2

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Uninformed Search

■ Also called as Blind Search or Brute Force Search.

■ A blind search is a search that has no information about its domain. The only thing

that a blind search can do is to distinguish a non-goal state from a goal state.

– Breadth-First search

– Depth-First search

– Uniform-Cost search

3

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth-First Search

■ Breadth-first search (BFS) is an algorithm for traversing or searching tree or

graph data structures.

■ It starts at the tree root and explores the neighbor nodes first, before moving

to the next level neighbors.

■ Breadth First Search explores the state space in a level by level fashion. Only

when there are no more states to be explored at a given level then the

algorithm move onto the next level.

4

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth-First Search

5

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth-First Search

Algorithm:

■ Step 01: Choose the starting node, mark it as visited, make it current node.

■ Step 02: Find adjacent unvisited node of current node, place it in Queue and

mark it visited.

■ Step 03: If no unvisited adjacent node found, dequeue node from Queue and

make it current node.

6

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

BFS Traversal: F B G A D I C E H

7

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = F

Queue:

Visited:

8

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = F

Queue:

Visited:

F B

9

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = F

Queue:

G B

Visited:

F B G

10

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = B

Queue:

Visited:

F B G

11

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = B

Queue:

A G

Visited:

F B G A

12

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = B

Queue:

D A G

Visited:

F B G A D

13

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = G

Queue:

D A

Visited:

F B G A D

14

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = G

Queue:

I D A

Visited:

F B G A D I

15

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = A

Queue:

I D

Visited:

F B G A D I

16

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = D

Queue:

Visited:

F B G A D I

17

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = D

Queue:

C I

Visited:

F B G A D I C

18

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = D

Queue:

E C I

Visited:

F B G A D I C E

19

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = I

Queue:

E C

Visited:

F B G A D I C E

20

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = I

Queue:

H E C

Visited:

F B G A D I C E H

21

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = C

Queue:

H E

Visited:

F B G A D I C E H

22

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = E

Queue:

Visited:

F B G A D I C E H

23

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = H

Queue:

Visited:

F B G A D I C E H

24

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue:

Visited:

F B G A D I C E H

BFS Traversal: F B G A D I C E H

25

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

1

Queue: Q R

1 4 2

6

W 1

Visited: S

2

3

7

T G

2

Current Node Opened Node Closed Node

26

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = S

1

Queue: Q R

1 4 2

6

W 1

Visited: S

S 2

3

7

T G

2

Current Node Opened Node Closed Node

27

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = S

1

Queue: Q R

1 4 2

Q

6

W 1

Visited: S

S Q 2

3

7

T G

2

Current Node Opened Node Closed Node

28

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = S

1

Queue: Q R

1 4 2

W Q

6

W 1

Visited: S

S Q W 2

3

7

T G

2

Current Node Opened Node Closed Node

29

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = S

1

Queue: Q R

1 4 2

T W Q

6

W 1

Visited: S

S Q W T 2

3

7

T G

2

Current Node Opened Node Closed Node

30

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = Q

1

Queue: Q R

1 4 2

T W

6

W 1

Visited: S

S Q W T 2

3

7

T G

2

Current Node Opened Node Closed Node

31

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = Q

1

Queue: Q R

1 4 2

R T W

6

W 1

Visited: S

S Q W T R 2

3

7

T G

2

Current Node Opened Node Closed Node

32

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = W

1

Queue: Q R

1 4 2

R T

6

W 1

Visited: S

S Q W T R 2

3

7

T G

2

Current Node Opened Node Closed Node

33

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = W

1

Queue: Q R

1 4 2

G R T

6

W 1

Visited: S

S Q W T R G 2

3

7

T G

2

Current Node Opened Node Closed Node

34

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = T

1

Queue: Q R

1 4 2

G R

6

W 1

Visited: S

S Q W T R G 2

3

7

T G

2

Current Node Opened Node Closed Node

35

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = R

1

Queue: Q R

1 4 2

G

6

W 1

Visited: S

S Q W T R G 2

3

7

T G

2

Current Node Opened Node Closed Node

36

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = G

1

Queue: Q R

1 4 2

6

W 1

Visited: S

S Q W T R G 2

3

7

T G

2

Current Node Opened Node Closed Node

37

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

1

Queue: Q R

1 4 2

6

W 1

Visited: S

S Q W T R G 2

3

7

T G

BFS Traversal: S Q W T R G 2

38

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

BFS Traversal: A B C D E F G H I J K L M

39

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth-First Search

Time Complexity and Space Complexity:

■ If we look at how BFS expands from the root we see that it first expands on a

set number of nodes, say b.

– On the second level it becomes b2.

– On the third level it becomes b3.

– And so on until it reaches bd for some depth d.

■ 1+ b + b2 + b3 + . . . . + bd which is O(bd)

■ Since all leaf nodes need to be stored in memory, space complexity is the same

as time complexity.

40

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth-First Search

■ As you can see BFS is:

– Very systematic

– Guaranteed to find a solution

– BFS is optimal (if cost = 1 per step). The path from initial state to goal state

is shallow.

41

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ Obviously this works best when the actions are reversible, and the set of goal

states is small.

42

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Initial State

9 …

4 5 6 7 8

2 3

1

Goal State

43

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

from the initial state j and backward from the goal, and stop when the two

searches meet in the middle.

44

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

1 Initial State

3 4

8 9 10 11 12

13 …

5 6 7

2 Goal State

45

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth-First Search

■ Depth-first search (DFS) is an algorithm for traversing or searching tree or

graph data structures. One starts at the root and explores as far as possible

along each branch before backtracking.

■ A depth first search begins at the root node (i.e. Initial node) and works

downward to successively deeper levels.

sequence. This process continues until a solution is found or backtracking is

forced by reaching a dead end.

46

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth-First Search

47

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth-First Search

Algorithm:

■ Step 01: Choose the starting node, mark it as visited, push it on Stack and make it

current node.

■ Step 02: Find adjacent unvisited node of current node, push it on Stack, mark it visited

and make it current node.

■ Step 03: If no unvisited adjacent node found, pop out node from Stack and make top of

the stack as current node.

48

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

DFS Traversal: F B A D C E G I H

49

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = F

Stack:

Visited:

50

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = B

Stack:

F B

Visited:

F B

51

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = A

Stack:

F B A

Visited:

F B A

52

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = B

Stack:

F B

Visited:

F B A

53

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = D

Stack:

F B D

Visited:

F B A D

54

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = C

Stack:

F B D C

Visited:

F B A D C

55

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = D

Stack:

F B D

Visited:

F B A D C

56

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = E

Stack:

F B D E

Visited:

F B A D C E

57

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = D

Stack:

F B D

Visited:

F B A D C E

58

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = B

Stack:

F B

Visited:

F B A D C E

59

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = F

Stack:

Visited:

F B A D C E

60

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = G

Stack:

F G

Visited:

F B A D C E G

61

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = I

Stack:

F G I

Visited:

F B A D C E G I

62

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = H

Stack:

F G I H

Visited:

F B A D C E G I H

63

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = I

Stack:

F G I

Visited:

F B A D C E G I H

64

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = G

Stack:

F G

Visited:

F B A D C E G I H

65

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = F

Stack:

Visited:

F B A D C E G I H

66

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Stack:

Visited:

F B A D C E G I H

DFS Traversal: F B A D C E G I H

67

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = S

1

Stack: Q R

1 4 2

S

6

W 1

Visited: S

S 2

3

7

T G

2

Current Node Opened Node Closed Node

68

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = Q

1

Stack: Q R

1 4 2

S Q

6

W 1

Visited: S

S Q 2

3

7

T G

2

Current Node Opened Node Closed Node

69

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = R

1

Stack: Q R

1 4 2

S Q R

6

W 1

Visited: S

S Q R 2

3

7

T G

2

Current Node Opened Node Closed Node

70

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = G

1

Stack: Q R

1 4 2

S Q R G

6

W 1

Visited: S

S Q R G 2

3

7

T G

2

Current Node Opened Node Closed Node

71

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = R

1

Stack: Q R

1 4 2

S Q R

6

W 1

Visited: S

S Q R G 2

3

7

T G

2

Current Node Opened Node Closed Node

72

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = W

1

Stack: Q R

1 4 2

S Q R W

6

W 1

Visited: S

S Q R G W 2

3

7

T G

2

Current Node Opened Node Closed Node

73

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = T

1

Stack: Q R

1 4 2

S Q R W T

6

W 1

Visited: S

S Q R G W T 2

3

7

T G

2

Current Node Opened Node Closed Node

74

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = W

1

Stack: Q R

1 4 2

S Q R W

6

W 1

Visited: S

S Q R G W T 2

3

7

T G

2

Current Node Opened Node Closed Node

75

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = R

1

Stack: Q R

1 4 2

S Q R

6

W 1

Visited: S

S Q R G W T 2

3

7

T G

2

Current Node Opened Node Closed Node

76

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = Q

1

Stack: Q R

1 4 2

S Q

6

W 1

Visited: S

S Q R G W T 2

3

7

T G

2

Current Node Opened Node Closed Node

77

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Current Node = S

1

Stack: Q R

1 4 2

S

6

W 1

Visited: S

S Q R G W T 2

3

7

T G

2

Current Node Opened Node Closed Node

78

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

1

Stack: Q R

1 4 2

6

W 1

Visited: S

S Q R G W T 2

3

7

T G

DFS Traversal: S Q R G W T 2

79

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

DFS Traversal: A B E K L C F G H M D I J

80

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

DFS Traversal: 8 3 1 6 4 7 10 14 13

81

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth-First Search

■ Since we don’t expand all nodes at a level, space complexity is modest. For branching

factor b and depth d, we require bd number of nodes to be stored in memory. This is

much better than bd.

■ In some cases, DFS can be faster than BFS. However, the worse case is still O(bd).

■ If you have deep search trees (or infinite – which is quite possible), DFS may end up

running off to infinity and may not be able to recover.

82

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ Depth-first search will not find a goal if it searches down a path that has

infinite length. So, in general, depth-first search is not guaranteed to find a

solution, so it is not complete.

■ This problem is eliminated by limiting the depth of the search to some value l.

However, this introduces another way of preventing depth-first search from

finding the goal: if the goal is deeper than l it will not be found.

83

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ Depth limited search is complete but not optimal.

■ If we choose a depth limit that is too small, then depth limited search is not

even complete.

■ The time and space complexity of depth limited search is similar to depth first

search.

84

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Level Depth Level Limit:

Visited

0 1 2 L=2

F F

FB F B

FBA F B A

FBA F B

FBAD F B D

FBAD F B

FBAD F

FBADG F G

FBADGI F G I

FBADGI F G

FBADGI F

FBADGI

85

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F Level 1

Visited: Level 2

F

Level 3

Current Node = F

86

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F B Level 1

Visited: Level 2

F B

Level 3

Current Node = B

87

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F B A Level 1

Visited: Level 2

F B A

Level 3

Current Node = A

88

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F B Level 1

Visited: Level 2

F B A

Level 3

Current Node = B

89

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F B D Level 1

Visited: Level 2

F B A D

Level 3

Current Node = D

90

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F B Level 1

Visited: Level 2

F B A D

Level 3

Current Node = B

91

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F Level 1

Visited: Level 2

F B A D

Level 3

Current Node = F

92

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F G Level 1

Visited: Level 2

F B A D G

Level 3

Current Node = G

93

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F G I Level 1

Visited: Level 2

F B A D G I

Level 3

Current Node = I

94

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F G Level 1

Visited: Level 2

F B A D G I

Level 3

Current Node = G

95

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

F Level 1

Visited: Level 2

F B A D G I

Level 3

Current Node = F

96

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 Level 0

Stack:

Level 1

Visited: Level 2

F B A D G I

Level 3

97

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Level Depth Level Limit:

Visited

0 1 2 L=2

S S 1

SQ S Q Q R

SQR S Q R 1 4 2

SQR S Q

SQRW S Q W 6

W 1

SQRW S Q S

SQRW S

2

SQRWT S T

3

SQRWTG S T G 7

SQRWTG S T

T G

SQRWTG S 2

SQRWTG

98

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S

6

W 1

Visited: S

S 2

3

7

Current Node = S T G

2

99

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S Q

6

W 1

Visited: S

S Q 2

3

7

Current Node = Q T G

2

100

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S Q R

6

W 1

Visited: S

S Q R 2

3

7

Current Node = R T G

2

101

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S Q

6

W 1

Visited: S

S Q R 2

3

7

Current Node = Q T G

2

102

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S Q W

6

W 1

Visited: S

S Q R W 2

3

7

Current Node = W T G

2

103

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S Q

6

W 1

Visited: S

S Q R W 2

3

7

Current Node = Q T G

2

104

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S

6

W 1

Visited: S

S Q R W 2

3

7

Current Node = S T G

2

105

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S T

6

W 1

Visited: S

S Q R W T 2

3

7

Current Node = T T G

2

106

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S T G

6

W 1

Visited: S

S Q R W T G 2

3

7

Current Node = G T G

2

107

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S T

6

W 1

Visited: S

S Q R W T G 2

3

7

Current Node = T T G

2

108

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

S

6

W 1

Visited: S

S Q R W T G 2

3

7

Current Node = S T G

2

109

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth Level Limit:

L=2 1

Stack: Q R

1 4 2

6

W 1

Visited: S

S Q R W T G 2

3

7

T G

DFS Limited Traversal: S Q R W T G 2

110

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ Depth-first search will not find a goal if it searches down a path that has

infinite length. So, in general, depth-first search is not guaranteed to find a

solution, so it is not complete.

■ This problem is eliminated by limiting the depth of the search to some value l.

However, this introduces another way of preventing depth-first search from

finding the goal: if the goal is deeper than l it will not be found.

111

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ If a depth-limited depth-first search limited to depth l does not find the goal,

try it again with limit at l+1. Continue this until goal is found.

greater values for the depth limit l.

■ Feels like breadth-first search, in that a level is fully explored before extending

the search to the next level. But, unlike breadth-first search, after one level is

fully explored, all nodes already expanded are thrown away and the search

starts with a clear memory.

112

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Limit = 0

113

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Limit = 1

114

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Limit = 2

115

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Limit = 3

116

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth First Search

■ If the first branch contains infinite

nodes and the goal is G (at second

branch).

■ The DFS will not reach the goal

because it will not be able to

backtrack from first branch.

■ DFS is not complete (It is not

guaranteed to find the goal)

117

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth First Search

are infinite, but the goal is present

in the solution.

. . . . .

■ BFS is complete (It is guaranteed

. . . . .

. . . . .

. . . . .

to find the goal, if it is present).

118

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Depth First Search

find the goal G2.

present in the solution G1 having path

cost 3.

return the optimal solution).

119

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Breadth First Search

find the goal G1.

present in the solution G2 having path

cost 2+3+2=7.

return the optimal solution).

120

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ Breadth-first search finds the shallowest goal state, but this may not always be

the least-cost solution for a general path cost function.

the lowest-cost node rather than the lowest-depth node.

121

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Algorithm:

■ Step 03: If the minimum path is goal, stop algorithm you found the solution.

■ Step 04: For each neighbor node v add expanded path < v ,P > to Queue.

122

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ S = Initial State

C

■ G = Goal State 3

2

2

A D G

Queue

4

Path Cost

2

5

5

S B

123

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<S> 0 3

2

2

A D G

4

2

5

From the path we have:

<S> = 0 5

S B

<A,S> = 2

<B,S> = 5 124

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<A,S> 2 3

2

<B,S> 5

2

A D G

4

2

5

From the path we have:

<A,S> = 2 5

S B

<C,A,S> = 4

<D,A,S> = 6 125

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<C,A,S> 4 3

2

<B,S> 5

<D,A,S> 6 2

A D G

4

2

5

From the path we have:

<C,A,S> = 4 5

S B

<D,C,A,S> = 7

126

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<B,S> 5 3

2

<D,A,S> 6

<D,C,A,S> 7 2

A D G

4

2

5

From the path we have:

<B,S> = 5 5

S B

<G,B,S> = 10

127

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<D,A,S> 6 3

2

<D,C,A,S> 7

<G,B,S> 10 2

A D G

4

2

5

From the path we have:

<D,A,S> = 6 5

S B

<G,D,A,S> = 8

128

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<D,C,A,S> 7 3

2

<G,D,A,S> 8

<G,B,S> 10 2

A D G

4

2

5

From the path we have:

<D,C,A,S> = 7 5

S B

<G,D,C,A,S> = 9

129

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue C

Path Cost

<G,D,A,S> 8 3

2

<G,D,C,A,S> 9

<G,B,S> 10 2

A D G

4

5

S→A→D→G 5

S B

As minimum path is the goal path, so we have found a solution.

130

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ S = Initial State

1

■ G = Goal State Q R

1 4 2

6

W 1

Queue S

Path Cost

2

3

7

T G

2

131

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost 1

Q R

<S> 0

1 4 2

6

W 1

S

2

From the path we have:

3

<S> = 0 7

<Q,S> = 1 T G

<W,S> = 6 2

<T,S> = 7 132

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost 1

Q R

<Q,S> 1

<W,S> 6

1 4 2

<T,S> 7

6

W 1

S

2

From the path we have: 3

7

<Q,S> = 1

T G

<R,Q,S> = 2 2

<W,Q,S> = 5 133

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost 1

Q R

<R,Q,S> 2

<W,Q,S> 5

1 4 2

<W,S> 6

6

<T,S> 7

W 1

S

2

From the path we have: 3

7

<R,Q,S> = 2

T G

<W,R,Q,S> = 4 2

<G,R,Q,S> = 3 134

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost 1

Q R

<G,R,Q,S> 3

<W,R,Q,S> 4

1 4 2

<W,Q,S> 5

6

<W,S> 6

W 1

S

<T,S> 7

2

Shortest Path = Solution = 3

7

S→Q→R→G

T G

2

As minimum path is the goal path, so we have found a solution.

135

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ B = Initial State

■ D = Goal State

Queue

Path Cost

136

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<B> 0

<B> = 0

<A,B> = 10

137

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<A,B> 10

<A,B> = 10

<C,A,B> = 22

<D,A,B> = 70 138

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<C,A,B> 22

<D,A,B> 70

<C,A,B> = 22

<D,C,A,B> = 54

Avoid Cycles (Discard them) 139

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<D,C,A,B> 54

<D,A,B> 70

B→A→C→D

140

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ D = Initial State

■ G = Goal State

Queue

Path Cost

141

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<D> 0

142

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<A,D> 2

<H,D> 6

<A,D> = 2

<B,A,D> = 10

<D,A,D> = 7 (It is a cycle as repeated D)

<E,A,D> = 9

Avoid Cycles (Discard them)

143

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<H,D> 6

<E,A,D> 9

<B,A,D> 10

144

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<E,H,D> 9

<E,A,D> 9

<B,A,D> 10

<I,H,D> 14

<E,H,D> = 9

<A,E,H,D> = 15

<D,E,H,D> = 18 (It is a cycle as repeated D)

Avoid Cycles (Discard them)

145

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<E,A,D> 9

<B,A,D> 10

<I,H,D> 14

<A,E,H,D> 15

<E,A,D> = 9

<A,E,A,D> = 15 (Cycle)

<D,E,A,D> = 18 (Cycle)

Avoid Cycles (Discard them)

146

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<E,B,A,D> 11

<I,H,D> 14

<A,E,H,D> 15

<C,B,A,D> 17

147

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<E,B,A,D> 11

<I,H,D> 14

<A,E,H,D> 15

<C,B,A,D> 17

<E,B,A,D> = 11

<A,E,B,A,D> = 18 (Cycle)

<D,E,B,A,D> = 20 (Cycle)

Avoid Cycles (Discard them)

148

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<I,H,D> 14

<A,E,H,D> 15

<C,B,A,D> 17

149

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<A,E,H,D> 15

<C,B,A,D> 17

<E,I,H,D> 23

<A,E,H,D> = 15

<D,A,E,H,D> = 20 (Cycle)

<E,A,E,H,D> = 22 (Cycle)

<B,A,E,H,D> = 23

Avoid Cycles (Discard them)

150

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<C,B,A,D> 17

<E,I,H,D> 23

<B,A,E,H,D> 23

<C,B,A,D> = 17

<B,C,B,A,D> = 27 (Cycle)

<F,C,B,A,D> = 24

<J,C,B,A,D> = 19

Avoid Cycles (Discard them)

151

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<J,C,B,A,D> 19

<E,I,H,D> 23

<B,A,E,H,D> 23

<F,C,B,A,D> 24

<J,C,B,A,D> = 19

<I,J,C,B,A,D> = 27

<C,J,C,B,A,D> = 23 (Cycle)

<G,J,C,B,A,D> = 22

Avoid Cycles (Discard them) 152

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<G,J,C,B,A,D> 22

<E,I,H,D> 23

<B,A,E,H,D> 23

<F,C,B,A,D> 24

<I,J,C,B,A,D> 27

153

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Queue

Path Cost

<G,J,C,B,A,D> 22

<E,I,H,D> 23

<B,A,E,H,D> 23

<F,C,B,A,D> 24

<I,J,C,B,A,D> 27

D→A→B→C→J →G

154

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

Repeated States

■ Failure to detect repeated states can turn a linear problem into an exponential

one!

155

By Engr. Ali Asghar Manjotho Lecturer CSE-MUET

■ Do not return to the state you just came from.

– Have the expand function refuse to generate any successor that is the same

state as the node’s parent.

– Have the expand function refuse to generate any successor of a node that is

the same as any of the node’s ancestors.

156

- my transcriptUploaded byapi-369423954
- IS NotesUploaded byapi-3834932
- Comparing NumbersUploaded byMr. Aulisio
- Call for PaperUploaded byAdam Hansen
- A star algorithmUploaded bySukhmeet Singh
- An Enumeration of Certain Equivalence Classes of Directed Multigraphs Having 0 to 5 Nodes with Each Node Having 2 Incoming and 2 Outgoing ArcsUploaded byCarey Briggs
- Computer Science BookletUploaded bymnaveed296167
- MCA 4th sem ADA lab mannualUploaded byNishanth Jain
- Assignment 2Uploaded byUtsav Dusad
- 4.4 Cube RootsUploaded byUmair Khan
- Data Cube TechnologyUploaded byRitu Kadyan
- gr12Uploaded byAman Gill
- Data Mining-Graph MiningUploaded byRaj Endran
- siprUploaded byCS & IT
- Moddel Trans From at Ion as an Optimization ProblemUploaded byasharaff08
- Algorithmic Graph TheoryUploaded bykumarbsnsp
- Mat Lab ProblemsUploaded byeagleeye
- Optimized AO* Algorithm for and-Or Graph SearchUploaded byIOSRjournal
- 20121108 Quiz 6b SolutionsUploaded byPaul Jones
- Seminar Report on Low Density Parity Check codesUploaded byPavan Suresh
- Tmca1_393Uploaded byPraful Kakde
- BE_IT_V_MO13_MSRUploaded bysandeep
- AMS301-Homework 7 SolutionsUploaded bySharmishtha Saxena
- AI Games Spring12Uploaded bypolodioxide
- Artficial Inteligence NotesUploaded byGarima Chadha
- Slab CoefficentUploaded byCeline Anne Vitug
- Mediators RahulUploaded byintisar ibrahim
- CNTKBook-20160121.pdfUploaded bypukkapad
- Graphs-1.pptUploaded byGul Sher
- Control systems-block reduction techniqueUploaded bySai Jaswanth

- Ee236a (Fall 2007-08)Uploaded bydebasis
- A Comparison of Channel Coding Schemes for 5GUploaded bySalma Belhadj
- Questions on Markov ChainUploaded byChandrashekhar Choudhari
- Intro to Advanced Applied Algorithms Nitk 2013Uploaded byDelenzy Cino
- Quiz1 ReviewUploaded byahawad
- pdaUploaded byTaqi Shah
- How to Implement AES in RubyUploaded bychris_hulbert
- 5. Binary Search TreesUploaded byAhmed Hosni
- TOC Assignment #2Uploaded byDishantGoyal
- Quantum Computing in Big Data Analytics: A Survey by Shaikh 2016Uploaded byAbhijeet
- PHPUploaded byDestroyer74
- GATEOverflow Book.pdfUploaded byAd Ri Ta
- UPenn_CIS160_HW15WUploaded byFirst Second
- Win32 API Declaration - CUploaded bymkapkr
- Network Flow ProblemsUploaded byKiên Trần Trung
- Arbenz Peter,Numerical Methods for Computational Science and EngineeringUploaded byanthalya
- POLYNOMIAL HIERARCHY COLLAPSESUploaded byreddituser
- ISEN 370 Exam 4 Notes (Wk 7-8)Uploaded byDaniel Medrano
- Chapter 8Uploaded bysaleem010
- e 174460Uploaded byanon_33416438
- Mastering Advanced Scala SampleUploaded bydeddalus9420
- C Programming NotesUploaded bynileshdeep
- Stochastic Gradient DescentUploaded bypenets
- IEE 376 - Operations Research Deterministic TechniquesApplications.pdfUploaded byPrakhar Aggarwal
- solution7.pdfUploaded byTrungNguyễnChí
- Cube solutionUploaded byWhat the hell it it
- Splitting algorithms for the multiple depot arc routing problem- application by ant colony optimizat.pdfUploaded byFrancysNava
- DAC and CADUploaded bySam Dy
- Tcs Assignment 1Uploaded byAbhi Manyu
- Notes 12Uploaded byhakito234

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.