0% found this document useful (0 votes)
3 views121 pages

CS-370-Week 2

The document outlines the conduct expectations and lecture topics for CS-370: Artificial Intelligence, taught by Dr. Hashir Kiani. Key topics include search algorithms such as Depth-First Search (DFS), Breadth-First Search (BFS), Iterative Deepening, and Uniform Cost Search, along with their properties. The document also emphasizes the importance of respectful behavior during class and provides a recap of previous lecture content.

Uploaded by

teamtroy3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
3 views121 pages

CS-370-Week 2

The document outlines the conduct expectations and lecture topics for CS-370: Artificial Intelligence, taught by Dr. Hashir Kiani. Key topics include search algorithms such as Depth-First Search (DFS), Breadth-First Search (BFS), Iterative Deepening, and Uniform Cost Search, along with their properties. The document also emphasizes the importance of respectful behavior during class and provides a recap of previous lecture content.

Uploaded by

teamtroy3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 121

CS-370: Artificial Intelligence

Week 2
Instructor: Dr. Hashir Kiani
General Conduct
• Do not talk amongst yourselves during the class

• Be respectful of others

• Only speak at your turn and preferably raise your hand if you want to
say something

• Do not cut off others when they are talking

• Do not use your mobile phone during the lecture

• Join the class on time

2
Lecture Outline
• Recap of Previous Lecture

• Search Tree

• BFS and DFS Properties

• Iterative Deepening

• Uniform Cost Search

3
Recap of Previous Lecture
• What is Search?
• Give some applications of Search.
• What is State? Initial State? Actions? Transition Model?
• What is state space? State space graph?
• What is goal test? Path cost? Solution? Optimal solution?
• What elements should be present in a data structure used to
implement a node?
• What algorithmic approach can be used to solve a search problem?
• What is the problem with this approach?
• What is a better approach that can be used?
4
Recap of Previous Lecture
• What kind of data structure is a stack?
• What is depth first search?
• What kind of data structure is a queue?
• What is breadth first search?

5
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Depth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Breadth-First Search

A
Search Tree
A
B

C D
E F G

I K
H J

L
M
112
BFS vs DFS

• When will BFS outperform DFS?

• When will DFS outperform BFS?


Search Algorithm Properties
• Complete: Guaranteed to find a solution if one exists
• Optimal: Guaranteed to find the least cost path
• Time complexity?
• Space complexity?
1 node
• In a search tree: …
b
b nodes
• b is the branching factor b2 nodes
• m is the maximum depth m tiers
• Number of nodes in entire tree?
• 1 + b + b2 + …. bm = O(bm)
bm nodes
Depth-First Search (DFS) Properties
• What nodes does DFS expand?
• Could process the whole tree!
• If m is finite, takes time O(bm)
b 1 node
• How much space does the frontier … b nodes
take? b2 nodes
• Only has siblings on path to root, so m tiers
O(bm)

• Is it complete?
• Yes, if we prevent cycles bm nodes

• Is it optimal?
• No, it finds the “leftmost” solution,
regardless of depth or cost
Breadth-First Search (BFS) Properties
• What nodes does BFS expand?
• Processes all nodes above shallowest
solution
• Let depth of shallowest solution be s b 1 node
• Search takes time O(bs) … b nodes
s tiers
b2 nodes
• How much space does the frontier
take? bs nodes
• Has roughly the last tier, so O(bs)

• Is it complete? bm nodes
• s must be finite if a solution exists, so
yes!

• Is it optimal?
• Only if costs are all the same.
Iterative Deepening Search
• Idea: get DFS’s space advantage with BFS’s
time / shallow-solution advantages
• Run a DFS with depth limit 1. If no solution… b
• Run a DFS with depth limit 2. If no solution… …

• Run a DFS with depth limit 3. …..

• Isn’t that wastefully redundant?


• Generally most work happens in the lowest
level searched, so not so bad!
Uniform Cost Search
• Start with a frontier as a priority queue using node cost
path as the priority.
• Start with an empty explored set.
• Add initial state to the frontier.
• Repeat:
• If the frontier is empty, then no solution.
• Remove a node from the frontier.
• If node contains goal state, return the solution.
• Add the node to the explored set.
• Expand node, add resulting nodes to the frontier if they
aren't already in the frontier or the explored set.
• If the child node is already in the frontier with higher path
cost then replace that frontier node with child
118
Uniform Cost Search
Frontier A 4
2 B

5 2
1
C D 6
Explored Set E F G
3 2 3
I 4 K 3
H 4 J 2
1
2 L
M
119
Uniform Cost Search Properties
• UCS is complete and optimal

• Explores options in every direction

• Does not use information about goal location.

120
Questions?
121

You might also like