80 likes | 254 Views
Topic 3 – Search Techniques. St Kentigern’s Academy Unit 3 – Artificial Intelligence. Search Trees. Many problems can be solved by a search tree.
E N D
Topic 3 – Search Techniques St Kentigern’s Academy Unit 3 – Artificial Intelligence
Search Trees • Many problems can be solved by a search tree. • The search techniques apply to a search tree which contains all the different choices possible when starting from one state and trying to reach a ‘goal’ state.
Search Trees • Here is a problem from Die Hard with a vengeance. • Water Jugs • There are two water jugs. One holds 4ltrs and one holds 3ltrs. You have an unlimited amount of water. The aim is to have exactly 2ltrs in the 4ltr jug. • You can: • Fill up the 4ltr jug • Fill up the 3ltr jug • Pour the 4ltr jug into the 3ltr jug • Pour the 3ltr jug into the 4ltr jug • Empty the 4ltr jug • Empty the 3ltr jug
Search Trees • Our start state is (0,0). This represents 0 litres of water in the 4ltr jug and 0ltrs of water in the 3ltr jug. • The goal state is (2,0). This represents 2 litres of water in the 4ltr jug and 0ltrs of water in the 3ltr jug.
Search Trees (0,0) (4,0) (0,3) (1,3) (4,3) (4,3) (3,0) (1,0) (0,1) (4,1) (2,3) (2,0)
Search Trees • There are two search techniques commonly used in these situations: • Breadth first; • Depth first
Search Trees • Breadth-first Search • This is when the tree is searched from left to right working its way down layer by layer until the goal is found. • The pathway through the tree is: • A, B, C, D, E, F, G, H, I, J, K, L A B C D E F G H I J K L
Search Trees • Depth-first Search • This is when the tree is searched going down the left side of the tree until we reach the lowest node and then moves back up to work down the right hand side. • The pathway through the tree is: • A, B, D, B, E, B, F, B, A, C, G, C, H, J, H, K, H, L, H, C, I A B C D E F G H I J K L