Lecture 3 Searching Algorithms in AI (1)
Lecture 3 Searching Algorithms in AI (1)
Searching - a process of finding the solution for a given set of problems. A searching
strategy is used to specify which path is to be selected to reach the solution.
Allan Ninyesiga
Problem-Solving Agents
• Imagine an agent enjoying a touring vacation
in Romania. The agent wants to take in the
sights, improve its Romanian, enjoy the
nightlife, avoid hangovers, and so on. The
decision problem is a complex one.
• Now, suppose the agent is currently in the
city of Arad and has a nonrefundable ticket
to fly out of Bucharest the following day. The
agent observes street signs and sees that
there are three roads leading out of Arad:
one toward Sibiu, one to Timisoara, and one
to Zerind. None of these are the goal, so
unless the agent is familiar with the
geography of Romania, it will not know
which road to follow
Problem-Solving Agents
• If the agent has no additional
information—that is, if the
environment is unknown—then
the agent can do no better than
to execute one of the actions at
random.
• Here we will assume our agents
always have access to information
about the world, such as the map
in Figure with that information,
the agent can follow this four-
phase problem-solving process:
Terminologies in Search Algorithms
• Solution: Sequence of actions that leads from the initial node to the
final node.
• Path Cost: A function that assigns a numeric cost to each path.
• Optimal Solution: The solution with the lowest cost.
• Problem Space: The environment in which the search takes place.
• Depth of a problem: Length of the shortest path from the initial state
to the final state.
Real-world problems
• We have already seen how the route-finding problem .
• Route-finding algorithms are used in a variety of applications such as
Web sites and in-car systems that provide driving directions, are
relatively straightforward extensions of the Romania example.
• Others, such as routing video streams in computer networks, military
operations planning, and airline travel-planning systems, involve
much more complex specifications.
• Consider the airline travel problems that must be solved by a travel
planning Web site:
Real-world problems: the airline travel problems
Properties of Search Algorithms
S---> A--->B---->C--->D---->G--->H--->E---->F---->I---->K
Breadth-first search
• Time Complexity: Time Complexity of BFS algorithm can be obtained by
the number of nodes traversed in BFS until the shallowest Node. Where
the d= depth of shallowest solution and b is a node at every state.
• T (b) = 1+b2+b3+.......+ bd= O (bd)
• Space Complexity: Space complexity of BFS algorithm is given by the
Memory size of frontier which is O(bd).
• Completeness: BFS is complete, which means if the shallowest goal node is
at some finite depth, then BFS will find a solution.
• Optimality: BFS is optimal if path cost is a non-decreasing function of the
depth of the node.
Breadth-first search
Depth-first Search
• Read about