Professional Documents
Culture Documents
Problem Solving
Problem Solving
SOLVING
Engr. Muzammil Iqbal
GENERATE AND TEST
Tester Correct
Possible Solutions Solutions
Solution
Generator
Incorrect
Solutions
REPRESENTATION OF
PROBLEM
Text form or description form
Graphical representation
Tree representation
Semantic networks
SWITCHING ON THE LIGHT
(GRAPHICAL FORM)
OFF OFF OFF
Farmer
Farmer
Fox Fox Goose Farmer
Fox
Goose Grain Goose
Grain
Grain
Farmer
Farmer Fox
Farmer Fox Fox
Goose Goose
Goose Grain Grain
Grain
Fox
Fox
Farmer
Goose
Farmer
Goose
Grain
Grain
FARMER & GOOSE PROBLEM
(TREE REPRESENTATION)
Fa, Fo, Gr, Go
Fa, Fo, Gr, Go Fa, Fo, Gr, Go Fa, Fo, Gr, Go Fa, Fo, Gr, Go Fa, Fo, Gr, Go Fa, Fo, Gr, Go
Airport
Q1
Q2
Q5 Q3 Q4
Hotel
TREE AND GRAPH
TERMINOLOGY
“A” is the “root node” A
“A, B, C … J” are “nodes” B C
“B” is a child of “A”
“A” is ancestor of “D” D
E F G
H
“D” is a descendant of “A”
“D, E, F, G, I, J” are “leaf nodes”
I
Arrows represent “edges” or “links”
J
PROBLEM FORMULATION
USING GRAPHS
3 3
A B C
2
4 4
S G
3 D E F 2
1 3
TREE SEARCH
S
D
A
E
B A
D F
B
C
E B
E A G
C
C
D B E
F
F
D F
C
G G
G
SEARCH STRATEGIES
Blind search – Uninformed
Goal directed
Data directed
Bidirectional
Depth First Search
Breadth First Search
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 have 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