SlideShare a Scribd company logo
1 of 29
What is Artificial
Intelligence
Lecture 01
Muhammad Rabbani
2
Types of search strategies
Blind/ Uninformed search
Informed/ Heuristic based search
Any path/ non-optimal search
Optimal path search
3
Performance measures
• Completeness:Is the algorithm guaranteed to
find a solution when there is one?
• Optimality:Does the strategy find the
optimal solution?
• Time complexity:How long does it take to
find a solution?
• Space Complexity:How much memory is
needed to perform the search?
Simple Search Algorithm
Let S be the start state
1. Initialize Q with the start node Q=(S) as only
entry; set Visited = (S)
2. If Q is empty, fail. Else pick node X from Q
3. If X is a goal, return X, we’ve reached the
goal
4. (Otherwise) Remove X from Q
5. Find all the children of node X not in Visited
6. Add these to Q; Add Children of X to
Visited
7. Go to Step 2
DFS: Example
S
BA
E FDC
G H
Q Visited
1
2
3
4
5
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2
3
4
5
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3
4
5
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 C,D,B S,A,B,C,D
4
5
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 C,D,B S,A,B,C,D
4 G,H,D,B S,A,B,C,D,G,H
5
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 C,D,B S,A,B,C,D
4 G,H,D,B S,A,B,C,D,G,H
5 H,D,B S,A,B,C,D,G,H
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 C,D,B S,A,B,C,D
4 G,H,D,B S,A,B,C,D,G,H
5 H,D,B S,A,B,C,D,G,H
6 D,B S,A,B,C,D,G,H
DFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 C,D,B S,A,B,C,D
4 G,H,D,B S,A,B,C,D,G,H
5 H,D,B S,A,B,C,D,G,H
6 D,B S,A,B,C,D,G,H
BFS: Example
S
BA
E FDC
G H
Q Visited
1
2
3
4
5
BFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2
3
4
5
BFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3
4
5
BFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 B,C,D S,A,B,C,D
4
5
BFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 B,C,D S,A,B,C,D
4
5
BFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 B,C,D S,A,B,C,D
4 C,D,E,F S,A,B,C,D,E,F
5
BFS: Example
S
BA
E FDC
G H
Q Visited
2 A,B S,A,B
3 B,C,D S,A,B,C,D
4 C,D,E,F S,A,B,C,D,E,F
5 D,E,F,G,H S,A,B,C,D,E,F,G,H
6
BFS: Example
S
BA
E FDC
G H
Q Visited
3 B,C,D S,A,B,C,D
4 C,D,E,F S,A,B,C,D,E,F
5 D,E,F,G,H S,A,B,C,D,E,F,G,H
6 E,F,G,H S,A,B,C,D,E,F,G,H
7
BFS: Example
S
BA
E FDC
G H
Q Visited
4 C,D,E,F S,A,B,C,D,E,F
5 D,E,F,G,H S,A,B,C,D,E,F,G,H
6 E,F,G,H S,A,B,C,D,E,F,G,H
7 F,G,H S,A,B,C,D,E,F,G,H
8
BFS: Example
S
BA
E FDC
G H
Q Visited
5 D,E,F,G,H S,A,B,C,D,E,F,G,H
6 E,F,G,H S,A,B,C,D,E,F,G,H
7 F,G,H S,A,B,C,D,E,F,G,H
8 G,H S,A,B,C,D,E,F,G,H
9
BFS: Example
S
BA
E FDC
G H
Q Visited
6 E,F,G,H S,A,B,C,D,E,F,G,H
7 F,G,H S,A,B,C,D,E,F,G,H
8 G,H S,A,B,C,D,E,F,G,H
9 H S,A,B,C,D,E,F,G,H
10
BFS: Example
S
BA
E FDC
G H
Q Visited
6 E,F,G,H S,A,B,C,D,E,F,G,H
7 F,G,H S,A,B,C,D,E,F,G,H
8 G,H S,A,B,C,D,E,F,G,H
9 S,A,B,C,D,E,F,G,H
10 S,A,B,C,D,E,F,G,H
BFS: Example
S
BA
E FDC
G H
Q Visited
1 S S
2 A,B S,A,B
3 B,C,D S,A,B,C,D
4 C,D,E,F S,A,B,C,D,E,F
5 D,E,F,G,H S,A,B,C,D,E,F,G,H
6 E,F,G,H S,A,B,C,D,E,F,G,H
7 F,G,H S,A,B,C,D,E,F,G,H
8 G,H S,A,B,C,D,E,F,G,H
9 H S,A,B,C,D,E,F,G,H
10 S,A,B,C,D,E,F,G,H
26
Properties of Breadth-first
search
• Complete? Yes (if b is finite)
• Time? 1+b+b2+b3+… +bd = O(bd)
• Space? O(bd+1) (keeps every node in memory)
• Optimal? Yes (if cost = 1 per step)
• Space is the bigger problem (more than time).
27
Properties of Depth-first
search
• Complete? No: fails in infinite-depth spaces, spaces
with loops
• Modify to avoid repeated states along path
• Complete in finite spaces
• Time? O(bm): terrible if m is much larger than d
• but if solutions are dense, may be much faster than
breadth-first
• Space? O(bm) (linear)
• Optimal? NO!
Problem with BFS
• Imagine searching a tree with branching
factor 8 and depth 10. Assume a node
requires just 8 bytes of storage. The
breadth first search might require up to:
= (8)10 nodes
= (23)10 X 23 = 233 bytes
= 8,000 Mbytes
= 8 Gbytes
Progressive Deepening
S
BA
E FDC
G H I J
K L M N

More Related Content

More from Nilt1234 (7)

Lec 17
Lec  17Lec  17
Lec 17
 
Lec 06
Lec 06Lec 06
Lec 06
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
introduction of Database
introduction of Databaseintroduction of Database
introduction of Database
 
Database Architecture
Database Architecture Database Architecture
Database Architecture
 
Entity Relationship Diagaram
Entity Relationship DiagaramEntity Relationship Diagaram
Entity Relationship Diagaram
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

What is Artificial Intelligence

  • 2. 2 Types of search strategies Blind/ Uninformed search Informed/ Heuristic based search Any path/ non-optimal search Optimal path search
  • 3. 3 Performance measures • Completeness:Is the algorithm guaranteed to find a solution when there is one? • Optimality:Does the strategy find the optimal solution? • Time complexity:How long does it take to find a solution? • Space Complexity:How much memory is needed to perform the search?
  • 4. Simple Search Algorithm Let S be the start state 1. Initialize Q with the start node Q=(S) as only entry; set Visited = (S) 2. If Q is empty, fail. Else pick node X from Q 3. If X is a goal, return X, we’ve reached the goal 4. (Otherwise) Remove X from Q 5. Find all the children of node X not in Visited 6. Add these to Q; Add Children of X to Visited 7. Go to Step 2
  • 5. DFS: Example S BA E FDC G H Q Visited 1 2 3 4 5
  • 6. DFS: Example S BA E FDC G H Q Visited 1 S S 2 3 4 5
  • 7. DFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 4 5
  • 8. DFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 C,D,B S,A,B,C,D 4 5
  • 9. DFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 C,D,B S,A,B,C,D 4 G,H,D,B S,A,B,C,D,G,H 5
  • 10. DFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 C,D,B S,A,B,C,D 4 G,H,D,B S,A,B,C,D,G,H 5 H,D,B S,A,B,C,D,G,H
  • 11. DFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 C,D,B S,A,B,C,D 4 G,H,D,B S,A,B,C,D,G,H 5 H,D,B S,A,B,C,D,G,H 6 D,B S,A,B,C,D,G,H
  • 12. DFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 C,D,B S,A,B,C,D 4 G,H,D,B S,A,B,C,D,G,H 5 H,D,B S,A,B,C,D,G,H 6 D,B S,A,B,C,D,G,H
  • 13. BFS: Example S BA E FDC G H Q Visited 1 2 3 4 5
  • 14. BFS: Example S BA E FDC G H Q Visited 1 S S 2 3 4 5
  • 15. BFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 4 5
  • 16. BFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 B,C,D S,A,B,C,D 4 5
  • 17. BFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 B,C,D S,A,B,C,D 4 5
  • 18. BFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 B,C,D S,A,B,C,D 4 C,D,E,F S,A,B,C,D,E,F 5
  • 19. BFS: Example S BA E FDC G H Q Visited 2 A,B S,A,B 3 B,C,D S,A,B,C,D 4 C,D,E,F S,A,B,C,D,E,F 5 D,E,F,G,H S,A,B,C,D,E,F,G,H 6
  • 20. BFS: Example S BA E FDC G H Q Visited 3 B,C,D S,A,B,C,D 4 C,D,E,F S,A,B,C,D,E,F 5 D,E,F,G,H S,A,B,C,D,E,F,G,H 6 E,F,G,H S,A,B,C,D,E,F,G,H 7
  • 21. BFS: Example S BA E FDC G H Q Visited 4 C,D,E,F S,A,B,C,D,E,F 5 D,E,F,G,H S,A,B,C,D,E,F,G,H 6 E,F,G,H S,A,B,C,D,E,F,G,H 7 F,G,H S,A,B,C,D,E,F,G,H 8
  • 22. BFS: Example S BA E FDC G H Q Visited 5 D,E,F,G,H S,A,B,C,D,E,F,G,H 6 E,F,G,H S,A,B,C,D,E,F,G,H 7 F,G,H S,A,B,C,D,E,F,G,H 8 G,H S,A,B,C,D,E,F,G,H 9
  • 23. BFS: Example S BA E FDC G H Q Visited 6 E,F,G,H S,A,B,C,D,E,F,G,H 7 F,G,H S,A,B,C,D,E,F,G,H 8 G,H S,A,B,C,D,E,F,G,H 9 H S,A,B,C,D,E,F,G,H 10
  • 24. BFS: Example S BA E FDC G H Q Visited 6 E,F,G,H S,A,B,C,D,E,F,G,H 7 F,G,H S,A,B,C,D,E,F,G,H 8 G,H S,A,B,C,D,E,F,G,H 9 S,A,B,C,D,E,F,G,H 10 S,A,B,C,D,E,F,G,H
  • 25. BFS: Example S BA E FDC G H Q Visited 1 S S 2 A,B S,A,B 3 B,C,D S,A,B,C,D 4 C,D,E,F S,A,B,C,D,E,F 5 D,E,F,G,H S,A,B,C,D,E,F,G,H 6 E,F,G,H S,A,B,C,D,E,F,G,H 7 F,G,H S,A,B,C,D,E,F,G,H 8 G,H S,A,B,C,D,E,F,G,H 9 H S,A,B,C,D,E,F,G,H 10 S,A,B,C,D,E,F,G,H
  • 26. 26 Properties of Breadth-first search • Complete? Yes (if b is finite) • Time? 1+b+b2+b3+… +bd = O(bd) • Space? O(bd+1) (keeps every node in memory) • Optimal? Yes (if cost = 1 per step) • Space is the bigger problem (more than time).
  • 27. 27 Properties of Depth-first search • Complete? No: fails in infinite-depth spaces, spaces with loops • Modify to avoid repeated states along path • Complete in finite spaces • Time? O(bm): terrible if m is much larger than d • but if solutions are dense, may be much faster than breadth-first • Space? O(bm) (linear) • Optimal? NO!
  • 28. Problem with BFS • Imagine searching a tree with branching factor 8 and depth 10. Assume a node requires just 8 bytes of storage. The breadth first search might require up to: = (8)10 nodes = (23)10 X 23 = 233 bytes = 8,000 Mbytes = 8 Gbytes