Share
Embed
Transcript
20 slides
-
DFS to find any string accepted 60 Stack 0 Put
start state + info into stack Visited is an empty set Visited Curr We add extra info to our stack. For this problem, a string “” -
DFS to find any string accepted 61 Stack 0 Visited
Curr We add extra info to our stack. For this problem, a string “” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 62 Stack 0 Visited
Curr We add extra info to our stack. For this problem, a string “” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 63 Stack 0 Visited
Curr We add extra info to our stack. For this problem, a string “” 0 Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 64 Stack 0 Visited
Curr We add extra info to our stack. For this problem, a string “” 0 3 “c” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 65 Stack 0 Visited
Curr We add extra info to our stack. For this problem, a string “” 0 3 “c” 2 “b” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 66 Stack 0 Visited
Curr We add extra info to our stack. For this problem, a string “” 0 3 “c” 2 “b” 1 “a” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 67 Stack 1 Visited
Curr We add extra info to our stack. For this problem, a string “a” 0 3 “c” 2 “b” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 68 Stack 1 Visited
Curr We add extra info to our stack. For this problem, a string “a” 0 1 3 “c” 2 “b” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 69 Stack 1 Visited
Curr We add extra info to our stack. For this problem, a string “a” 0 1 1 “ab” 3 “c” 2 “b” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 70 Stack 1 Visited
Curr We add extra info to our stack. For this problem, a string “a” 0 1 1 “ab” 3 “c” 2 “b” 1 “ac” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 71 Stack 1 Visited
Curr We add extra info to our stack. For this problem, a string “a” 0 1 1 “ab” 3 “c” 2 “b” 1 “ac” 2 “aa” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 72 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 “aa” 1 “ab” 3 “c” 2 “b” 1 “ac” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 73 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 “aa” 2 1 “ab” 3 “c” 2 “b” 1 “ac” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 74 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 “aa” 2 1 “ab” 3 “c” 2 “b” 1 “ac” 3 “aac” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 75 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 “aa” 2 1 “ab” 3 “c” 2 “b” 1 “ac” 3 “aac” 4 “aab” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 76 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 “aa” 2 1 “ab” 3 “c” 2 “b” 1 “ac” 3 “aac” 4 “aab” 1 “aaa” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 77 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 1 “ab” 3 “c” 2 “b” 1 “ac” 3 “aac” 4 “aab” 1 “aaa” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 78 Stack Visited Curr
We add extra info to our stack. For this problem, a string 0 1 2 1 “ab” 3 “c” 2 “b” 1 “ac” 3 “aac” 4 “aab” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo -
DFS to find any string accepted 79 Stack Visited Curr
0 1 2 1 “ab” 3 “c” 2 “b” 1 “ac” 3 “aac” 4 “aab” Repeat until goal is met curr, info = pop from stack if curr is not in visited add curr to visited for each v adjacent to curr push v, newinfo For this problem, goal = accepting state, The info is the string to get us there.