AIML Module-01
AIML Module-01
MODULE- 01
INTRODUCTION TO ARTIFICIAL INTELLIGENCE
WHAT IS AI?
In Figure 1.1 shows the eight definitions of AI, laid out along two dimensions.
The definitions on top are concerned with thought processes and reasoning, whereas the ones on the
bottom address behavior.
The definitions on the left measure success in terms of fidelity to human performance.
RATIONALITY the ones on the right measure against an ideal performance measure, called
rationality. A system is rational if it does the ―right thing,‖ given what it knows.
Historically, all four approaches to AI have been followed, each by different people with different
methods.
A rationalist1 approach involves a combination of mathematics and engineering.
The Turing Test, proposed by Alan Turing (1950), was designed to provide a satisfactory
operational definition of intelligence.
A computer passes the test if a human interrogator, after posing some written questions, cannot tell
whether the written responses come from a person or from a computer.
Programming a computer to pass a rigorously applied test provides plenty to work on.
The computer would need to possess the following capabilities:
o NATURAL LANGUAGE PROCESSING to enable it to communicate successfully in
English;
o KNOWLEDGE REPRESENTATION to store what it knows or hears;
o AUTOMATED REASONING to use the stored information to answer questions and to
draw new conclusions;
o MACHINE LEARNING to adapt to new circumstances and to detect and extrapolate
patterns.
Turing’s test deliberately avoided direct physical interaction between the interrogator and the
computer, because physical simulation of a person is unnecessary for intelligence.
However the so-called total Turing Test includes a video signal so that the interrogator can test the
subject’s perceptual abilities, as well as the opportunity for the interrogator to pass physical objects
―through the hatch.‖
To pass the total Turing Test, the computer will need
o COMPUTER VISION to perceive objects, and
o ROBOTICS to manipulate objects and move about.
These six disciplines compose most of AI, and Turing deserves credit for designing a test that
remains relevant 60 years later.
The interdisciplinary field of cognitive science brings together computer models from AI and
experimental techniques from psychology to construct precise and testable theories of the human
mind.
o First, it is more general than the ―laws of thought‖ approach because correct inference is
just one of several possible mechanisms for achieving rationality.
o Second, it is more amenable to scientific development than are approaches based on
human behavior or human thought.
The standard of rationality is mathematically well defined and completely general, and can be
―unpacked‖ to generate agent designs that provably achieve it.
Human behavior, on the other hand, is well adapted for one specific environment and is defined the
sum total of all the things that humans do.
Some speculated that machines might not just do calculations but actually be able to think and act on
their own.
It’s one thing to say that the mind operates, at least in part, according to logical rules, and to build
physical systems that emulate some of those rules; it’s another to say that the mind itself is such a
physical system.
Ren´e Descartes (1596–1650) gave the first clear discussion of the distinction between mind and
matter and of the problems that arise.
Descartes was a strong advocate of the power of reasoning in understanding the world, a philosophy
now called RATIONALISM.
But Descartes was also a proponent of dualism. He held that there is a part of the human mind that is
outside of nature, exempt from physical laws. Animals, on the other hand, did not possess this dual
quality; they could be treated as machines.
An alternative to dualism is MATERIALISM, which holds that the brain’s operation according to the
laws of physics constitutes the mind.
Given a physical mind that manipulates knowledge, the next problem is to establish EMPIRICISM the
source of knowledge.
Mathematics
1. What are the formal rules to draw valid conclusions?
2. What can be computed?
3. How do we reason with uncertain information?
Philosophers staked out some of the fundamental ideas of AI, but the leap to a formal science required
a level of mathematical formalization in three fundamental areas: logic, computation, and probability.
The idea of formal logic can be traced back to the philosophers of ancient Greece, but its mathematical
development really began with the work of George Boole who worked out the details of propositional,
or Boolean, logic (Boole, 1847).
In 1879, Gottlob Frege (1848–1925) extended Boole’s logic to include objects and relations, creating
the firstorder logic that is used today.
The first nontrivial algorithm is thought to be Euclid’s algorithm for computing greatest common
divisors.
The word algorithm comes from al-Khowarazmi, a Persian mathematician of the 9th century, whose
writings also introduced Arabic numerals and algebra to Europe.
Boole and others discussed algorithms for logical deduction, and, by the late 19th century, efforts were
under way to formalize general mathematical reasoning as logical deduction.
In 1930, Kurt Godel (1906–1978) showed that there exists an effective procedure to prove any true
statement in the first-order logic of Frege and Russell, but that first-order logic could not capture the
principle of mathematical induction needed to characterize the natural numbers.
Economics
1. How should we make decisions so as to maximize payoff?
2. How should we do this when others may not go along?
3. How should we do this when the payoff may be far in the future?
The science of economics got its start in 1776, when Scottish philosopher Adam Smith (1723–1790)
published An Inquiry into the Nature and Causes of the Wealth of Nations.
While the ancient Greeks and others had made contributions to economic thought, Smith was the first
to treat it as a science, using the idea that economies can be thought of as consisting of individual
agents maximizing their own economic well-being.
Most people think of economics as being about money, but economists will say that they are really
studying how people make choices that lead to preferred outcomes.
The mathematical treatment of ―preferred outcomes‖ or utility was first formalized by L´eon Walras
(pronounced ―Valrasse‖) (1834-1910) and was improved by Frank Ramsey (1931) and later by John
von Neumann and Oskar Morgenstern.
Decision theory, which combines probability theory with utility theory, provides a formal and
complete framework for decisions made under uncertainty.
This is suitable for ―large‖ economies where each agent need pay no attention to the actions of other
agents as individuals.
For ―small‖ economies, the situation is much more like a game: the actions of one player can
significantly affect the utility of another.
Von Neumann and Morgenstern’s development of GAME THEORY included the surprising result
that, for some games.
Unlike decision theory, game theory does not offer an unambiguous prescription for selecting actions.
For the most part, economists did not address the third question listed above, namely, how to make
rational decisions when payoffs from actions are not immediate but instead result from several actions
taken in sequence.
This topic was pursued in the field of OPERATIONS RESEARCH, which emerged in World War II
from efforts in Britain to optimize radar installations, and later found civilian applications in complex
management decisions.
Work in economics and operations research has contributed much. The pioneering AI researcher
Herbert Simon (1916–2001) won the Nobel Prize in economics in 1978 for his early work showing
that models based on SATISFICING—making decisions that are ―good enough,‖
Neuroscience
1. How do brains process information?
Neuroscience is the study of the nervous system, particularly the brain.
Although the exact way in which the brain enables thought is one of the great mysteries of science, the
fact that it does enable thought has been appreciated for thousands of years because of the evidence
that strong blows to the head can lead to mental incapacitation.
Paul Broca (1824-1880) investigation of aphasia in 1861 in the left hemisphere of brain which is
responsible for speech production, it was noticed that brain is the collection of large cells called
neurons.
1873: Camillo Golgi developed a staining technique allowing observation of brain cells which was
used by Ramon Cajal to point out that collection of simple cells can lead to thoughts, actions, and
consciousness, Brain causes mind.
1929-Hansberg (EEG) & fMRI(Ogwan) provide the details of ongoing cognitive actions in brain.
Optogenetics (crick, 1999) allows both measurement and control of individual neurons on light
sensitivity
There is almost no theory on how an individual memory is stored and how higher cognitive functions
operate.
Brain machine interface was developed (Lebedev and nicolelis, 2006) for both sensing and motor
control not only promises to restore the function to disabled individuals, but also sheds light on neural
systems, remarkable finding of this study is brain is able to adjust itself to interface successfully with
an external device treating the device as an sensing organ or limb.
Psychology
1. How do humans and animals think and act?
German physicist Hermann von Helmholtz (1821-1894) and his student Wilhelm Wundt (1832-1920).
Wundt opened the first laboratory of experimental psychology, at the University of Leipzig.
Wundt insisted on carefully controlled experiments in which his workers would perform a perceptual
or associative task while introspecting on their thought processes.
Behaviourism H. S. Jennings (1906) Behaviorists insisted on studying only objective meatures of the
percepts (or stimulus) given to an animal and its resulting actions (or response). Behaviorism
discovered a lot about rats and pigeons but had less success at understanding humans.
Cognitive psychology: views the brain as an information-processing device. Craik (1943) specified the
three key steps of a knowledge-based agent:
(1) the stimulus must be translated into an internal representation,
Computer engineering
1. How can we build an efficient computer?
1940: The first operational computer was the electromechanical Heath Robinson, built by Alan
Turing's team for a single purpose: deciphering German messages 4
1943, the same group developed the Colossus, a powerful general-purpose machine based on vacuum
tubes.
1941: The first operational programmable computer was the Z-3, the invention of Konrad Zuse in
Germany
1940 and 1942: The first electronic computer, the ABC, was assembled by John Atanasoff and his
student Clifford Berry between at lowa State University,
It was the ENIAC, developed as part of a secret military project at the University of Pennsylvania by
a team including John Mauchly and John Eckert, that proved to be the most influential forerunner of
modern computers.
Performance doubled every 18 months or so until around 2005.
Charles Babbage (1792-1871) designed two machines, neither of which he completed. The
Difference Engine was intended to compute mathematical tables for engineering and scientific
projects. It was finally built and shown to work in 1991 at the Science Museum in London (Swade,
2000).
Babbage's Analytical Engine was far more ambitious: it included addressable memory, stored
programs, and conditional jumps and was the first artifact capable of universal computation.
Ada Lovelace wrote programs for the unfinished Analytical Engine and
even speculated that the machine could play chess or compose music.
Software side of computer science has supplied the operating systems activate programming
languages, and tools needed to write modern programs.
Control theory and cybernetics
1. How can artifacts operate under their own control?
Control theory was created by Norbert Wiener (1894-1964) who studied biological and mechanical
control systems and their connection to cognitive systems.
Ktesibios of Alexandria (c. 250 B.C.) built the first self-controlling machine: a water clock with a
regulator that maintained a constant flow rate.
Steam engine governor, created by James Watt (1736-1819) Thermostat, invented by Cornelis
Drebbel (1572-1633) Cybernatics: was a feedback mechanism
Homeostatic: Intelligence could be created by the use of homeostatic devices containing
appropriate feedback loops to achieve stable adaptive behavior.
Objective and cost function: Modern control theory, especially the branch known as stochastic
optimal control, has as its goal the design of systems that maximize an objective function and
reduces cost function over time.
Linguistics
1. How does language relate to thought?
In 1957, B. F. Skinner published Verbal Behavior. This was a comprehensive, detailed account of
the behaviorist approach to language learning.
Noam Chomsky, published a book on his own theory, Syntactic Structures. Chomsky pointed out
that the behaviorist theory did not address the notion of creativity in language-it did not explain
how a child could understand and make up sentences that he or she had never heard before.
Computational linguistics or natural language processing: Understanding language requires an
understanding of the subject matter and context, not just an understanding of the structure of
sentences.
Computers where designed for arithmetic operations and nothing else but Al researchers
intellectual establishment, by and large, preferred to believe that "a machine can never do X."
They focused on the tasks including games, puzzles, mathematics, and IQ
General Problem Solver, or GPS. Newell and Simon's early success was followed up with the
GPS, Unlike Logic Theorist, this program was designed from the start to imitate human
problem-solving protocols. Within the limited class of puzzles it could handle, it turned out that
the order in which the program considered subgoals and possible actions was similar to that in
which humans approached the same problems.
Physical symbol system hypothesis, which states that "a physical symbol system has the
necessary and sufficient means for general intelligent action." What they meant is that any
system (human or machine) exhibiting intelligence must operate by manipulating data structures
composed of symbols.
At IBM, Nathaniel Rochester and his colleagues produced some of the first Al programs.
1952, Arthur Samuel wrote a series of programs for checkers (draughts) that eventually learned
to play at a strong amateur level.
1958. In MIT Al Lab, Mc-Carthy defined the high-level language Lisp, that has dominated the
next 30 years Al programming language.
1958 Mc-Carthy published a paper entitled Programs with Common Sense, in which he
described the Advice Taker, a hypothetical program that can be seen as the first complete Al
system
1959: Herbert Gelernter constructed the Geometry Theorem Prover, which was able to prove
theorems of mathematics that students would find quite tricky.
James Slagle's SAINT program (1963) was able to solve closed-form calculus integration
problems typical of first-year college courses.
Tom Evans's ANALOGY program (1968) solved geometric analogy problems that appear in IQ
tests.
Hebb's learning methods were enhanced by Bernie Widrow (Widrow and Hoff, 1960; Widrow,
1962), who called his networks adalines, and by Frank Rosenblatt (1962) with his perceptions.
The perceptron convergence theorem (Block et al., 1962) says that the learning algorithm can
adjust the connection strengths of a perceptron to match any input data, provided such a match
exists.
A dose of reality (1966- 1973)
"Visible future" Simon made more concrete predictions: that within 10 years a computer would
be chess champion, and a significant mathematical theorem would be proved by machine. These
predictions came true (or approximately true) within 40 years rather than 10.
Simon's overconfidence was due to the promising performance of early Al systems on simple
examples. In almost all cases, however, these early systems turned out to fail miserably when
tried out on wider selections of problems and on more difficult problems.
Reasons for failure?
1. Al systems where based on informed inspection (how human think to solve the problem
instead of critical analysis and algorithm).
2. Intractability of many of the problems that Al was trying to solve.
3. Early Al systems worked effectively for micro world programs. And could not scale well.
4. Basic structure used to represent the intelligent nature was based on perceptron which
limited in representing limited data.
Expert systems (1969-1986)
Early Al systems had adopted the general purpose search mechanism to solve the problem which
proved to be weak as it did not scale up on large data.
The first kind of difficulty arose because most early programs knew nothing of their subject
matter, they succeeded by means of simple syntactic manipulations
The alternative to the weak methods is to use more powerful, domain specific knowledge system
that allows larger reasoning steps and can easily handle typical occurring cases in narrow
expertise.
To solve the more hard problem, you must know the result. DENDRAL program was an
example of this type
Expert systems are more knowledge-intensive systems, stanford began Heuristic programming
project (HPP) to understand how new method of expert system can be applied to other areas.
MYCIN was system to diagnose the blood infection based on 450 rules and was better than
junior doctors which employed calculus of uncertainty called certainty factors to fit well with
how doctors diagnose on impact of evidence on the diagnosis.
Al becomes an industry (1980- present)
The first successful commercial expert system began operation at the Digital Equipment
Corporation (McDermott, 1982).
The program helped configure orders for new computer systems; by 1986, it was saving the
company an estimated $40 million a year.
By 1988. DEC's Al group had 40 expert systems deployed, with more on the way. DuPont had
100 in use and 500 in development, saving an estimated $10 million a year. Nearly every major
U.S. corporation had its own Al group and was either using or investigating expert systems.
In 1981, the Japanese announced the "Fifth Generation" project, a 10-year plan to build
intelligent computers running Prolog.
The big data has opened the opportunity for ML algorithms and the most of them are un labeled
data.
Big data was the crucial factor in the 2011 victory of the IBM's watson's system over the human
champion in jeopardy quiz game.
Deep learning
Deep learning refers to the ML using multiple layers of simple, adjustable computing elements.
During 1970 experiments were conducted in the name of CNN's they found some success in
handwritten recognition.
imageNet competition in 2012 which required the classifying images into one of the thousand
categories.
Deep learning has reported gains in the speech recognition, Machine translation, medical
diagnosis, and game playing.
The use of deep learning network to represent the evaluation function contributed tote Windows
the ALPHAGO's victory over leading human Go player in 2016,2017,2018.
PROBLEM-SOLVING AGENTS
Problem solving agent uses atomic representation. That is state of world is considered as wholes,
with no internal structure visible to the problem solving algorithm.
Goal based agents that use more advanced factored or structured representation is usually called
planning agents.
Intelligent agents are supposed to maximize their performance measure. Problem Solving Agents
decide what to do by finding a sequence of actions that leads to a desirable state or solution.
The problem solving agent follows this four phase problem solving process:
1. Goal formulation, based on the current situation and the agent’s performance measure, is the
first step in problem solving.
2. Problem formulation is the process of deciding what actions and states to consider, given a
goal. An agent with several immediate options of unknown value can decide what to do by first
examining future actions that eventually lead to states of known value.
If we assume that the environment is observable, the agent always knows the current state. If we
assume that the environment is deterministic, each action has exactly one outcome. Under these
assumptions, the solution to any problem is a fixed sequence of actions.
3. The process of looking for a sequence of actions that reaches the goal is called search.
4. A search algorithm takes a problem as input and returns a solution in the form of an action
sequence. Once a solution is found, the actions it recommends can be carried out. This is called
the execution phase. After formulating a goal and a problem to solve, the agent calls a search
procedure to solve it.
5. Once the solution has been executed, the agent will formulate a new goal.
A simple ―formulate, search, execute‖ design for the agent, as shown in the Figure 3.1.
The state space forms a graph in which the nodes are states and the links between nodes are
actions.
A path in the state space is a sequence of states connected by a sequence of actions.
4. GOAL TEST:
The goal test determines whether a given state is a goal state.
5. PATH COST:
A path cost function that assigns a numeric cost to each path.
The problem-solving agent chooses a cost function that reflects its own performance
measure.
The cost of a path can be described as the sum of the costs of the individual actions along
the path.
The step cost of taking action a in state s to reach state s′ is denoted by c(s, a, s′).
A solution to a problem is an action sequence that leads from the initial state to a goal state.
Solution quality is measured by the path cost function, and an optimal solution has the lowest path
cost among all solutions.
Formulating problems
Formulation seems reasonable but it is still a model- an abstract mathematical description not the
real thing.
The process of removing detail from a representation is called abstraction
In additions to abstracting the state description, one must abstract the actions themselves.
The abstraction is valid if we can expand any abstract solution into a solution in the
more detailed world
The abstraction is useful if carrying out each of the actions in the solution is easier than the
original problem.
The choice of a good abstraction thus involves removing as much detail as possible while
retaining validity and ensuring that the abstract actions are easy to carry out.
EXAMPLE PROBLEMS
The problem-solving approach has been applied to a vast array of task environments.
We list some of the best known here, distinguishing between toy and real-world problems.
A TOY PROBLEM toy problem is intended to illustrate or exercise various problem-solving
methods.
A REAL-WORLD PROBLEM is one whose solutions people actually care about. Such problems
tend not to have a single agreed-upon description, but can give the general flavor of their
formulations.
TOY PROBLEMS
1. VACUUM WORLD
This can be formulated as a problem as follows:
States: The state is determined by both the agent location and the dirt locations. The agent is in one
of two locations, each of which might or might not contain dirt. Thus, there are 2 × 22 = 8 possible
world states. A larger environment with n locations has n · 2n states.
Initial state: Any state can be designated as the initial state.
Actions: In this simple environment, each state has just three actions: Left, Right, and Suck. Larger
environments might also include Up and Down.
Transition model: The actions have their expected effects, except that moving Left in the leftmost
square, moving Right in the rightmost square, and Sucking in a clean square have no effect.
Goal test: This checks whether all the squares are clean.
Path cost: Each step costs 1, so the path cost is the number of steps in the path.
2. 8-PUZZLE
The 8-puzzle belongs to the family of sliding-block puzzles, which are often used as SLIDING-
BLOCK PUZZLES test problems for new search algorithms in AI.
The 8-puzzle has 9! / 2 = 181, 440 reachable states and is easily solved.
The 8-puzzle consists of a 3×3 board with eight numbered tiles and a blank space. A tile adjacent to
the blank space can slide into the space.
States: A state description specifies the location of each of the eight tiles and the blank in one of
the nine squares.
Initial state: Any state can be designated as the initial state. Any given goal can be reached from
exactly half of the possible initial states.
Actions: The simplest formulation defines the actions as movements of the blank space Left,
Right, Up, or Down. Different subsets of these are possible depending on where the blank is.
Transition model: Given a state and action, this returns the resulting state; for example, if we
apply Left to the start state in Figure, the resulting state has the 5 and the blank switched.
Goal test: This checks whether the state matches the goal configuration shown in Figure 3.4.
(Other goal configurations are possible.)
Path cost: Each step costs 1, so the path cost is the number of steps in the path.
3. 8-QUEENS PROBLEM
The goal of the 8-queens problem is to place eight queens on a chessboard such that no queen
attacks any other (A queen attacks any piece in the same row, column or diagonal).
Although efficient special-purpose algorithms exist for this problem and for the whole n-queens
family, it remains a useful test problem for search algorithms.
There are two main kinds of formulation.
An incremental formulation involves operators that augment the state description, starting
with an empty state; for the 8-queens problem, this means that each action adds a queen to the
state.
A complete-state formulation starts with all 8 queens on the board and moves them around.
In either case, the path cost is of no interest because only the final state counts.
The first incremental formulation one might try is the following:
ROUTE-FINDING PROBLEM
The route-finding problem is defined in terms of specified locations and transitions along links
between them.
Route-finding algorithms are used in a variety of applications. Some, 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:
States: Each state obviously includes a location (e.g., an airport) and the current time.
Initial state: This is specified by the user’s query.
Actions: Take any flight from the current location, in any seat class, leaving after the current time,
leaving enough time for within-airport transfer if needed.
Transition model: The state resulting from taking a flight will have the flight’s destination as the
current location and the flight’s arrival time as the current time.
Goal test: Are we at the final destination specified by the user?
Path cost: This depends on monetary cost, waiting time, flight time, customs and immigration
procedures, seat quality, time of day, type of airplane, frequent-flyer mileage awards, and so on.
Touring problems
Are closely related to route-finding problems, but with an important difference.
Consider, for example, the problem ―Visit every city in Figure at least once, starting and ending in
Bucharest.‖
As with route finding, the actions correspond to trips between adjacent cities.
The state space, however, is quite different. Each state must include not just the current location
but also the set of cities the agent has visited.
So the initial state would be In(Bucharest), Visited({Bucharest}), a typical intermediate state
would be In(Vaslui), Visited({Bucharest, Urziceni, Vaslui}), and the goal test would check
whether the agent is in Bucharest and all 20 cities have been visited.
VLSI LAYOUT
In addition to planning trips for traveling salespersons, these algorithms have been used for tasks
such as planning movements of automatic circuit-board drills and of stocking machines on shop
floors.
A VLSI layout problem requires positioning millions of components and connections on a chip to
minimize area, minimize circuit delays, minimize stray capacitances, and maximize
manufacturing yield.
The layout problem comes after the logical design phase and is usually split into two parts: cell
layout and channel routing.
Search algorithms all share this basic structure; they vary primarily according to how they
choose which state to expand next—the so-called search strategy.
A repeated state in the search tree, may get generated in case if it has a loopy path.
Loopy paths are a special case of the more general concept of redundant paths, which exist
whenever there is more than one way to get from one state to another.
Any goal state that is reachable by extending one path is also reachable by extending the other.
In some cases, it is possible to define the problem itself so as to eliminate redundant paths.
In other cases, redundant paths are unavoidable. This includes all problems where the actions are
reversible, such as route-finding problems and sliding-block puzzles.
This is true even for algorithms that know how to avoid infinite loops.
Algorithms that forget their history are doomed to repeat it. The way to avoid exploring
redundant paths is to remember where one has been.
To do this, one should augment the TREE-SEARCH algorithm with a data structure called the
explored set, which remembers every expanded node.
Newly generated nodes that match previously generated nodes—ones in the explored set or the
frontier—can be discarded instead of being added to the frontier.
Given the components for a parent node, it is easy to see how to compute the necessary
components for a child node.
The function CHILD-NODE takes a parent node and an action and returns the resulting child
node:
The node data structure is depicted in Figure. The PARENT pointers string the nodes together
into a tree structure.
These pointers also allow the solution path to be extracted when a goal node is found; use the
SOLUTION function to return the sequence of actions obtained by following parent pointers
back to the root.
A node is a bookkeeping data structure used to represent the search tree. A state corresponds to a
configuration of the world.
Thus, nodes are on particular paths, as defined by PARENT pointers, whereas states are not.
Furthermore, two different nodes can contain the same world state if that state is generated via
two different search paths.
The frontier needs to be stored in such a way that the search algorithm can easily choose the next
node to expand according to its preferred strategy.
The appropriate data structure for this is a queue. The operations on a queue are as follows:
o EMPTY?(queue) returns true only if there are no more elements in the queue.
o POP(queue) removes the first element of the queue and returns it.
All they can do is generate successors and distinguish a goal state from a non-goal state.
All search strategies are distinguished by the order in which nodes are expanded.
Strategies that know whether one non-goal state is ―more promising‖ than another are called
informed search or heuristic search strategies.
Following are the various types of uninformed search algorithms:
o Breadth-first Search
o Depth-first Search
o Depth-limited Search
o Iterative deepening depth-first search
o Uniform cost search
o Bidirectional Search
Breadth-first search
Breadth-first search is a simple strategy in which the root node is expanded first, then all the
successors of the root node are expanded next, then their successors, and so on.
In general, all the nodes are expanded at a given depth in the search tree before any nodes at the
next level are expanded.
Breadth-first search is an instance of the general graph-search algorithm in which the shallowest
unexpanded node is chosen for expansion. This is achieved very simply by using a FIFO queue
for the frontier.
Thus, new nodes (which are always deeper than their parents) go to the back of the queue, and
old nodes, which are shallower than the new nodes, get expanded first.
Breadth-first search always has the shallowest path to every node on the frontier.
Pseudo code for Breadth Frist Search is as follows
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 is optimal if the path cost is a nondecreasing function of the depth of the
node. The most common such scenario is that all actions have the same cost.
Advantages:
o BFS will provide a solution if any solution exists.
o If there are more than one solutions for a given problem, then BFS will provide the
minimal solution which requires the least number of steps.
Disadvantages:
o It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
o BFS needs lots of time if the solution is far away from the root node.
Example
Consider a graph with 5 vertices as shown below
We start from vertex 0, the BFS algorithm starts by putting it in the Visited list and putting all its
adjacent vertices in the stack.
Next, we visit the element at the front of queue i.e. 1 and go to its adjacent nodes. Since 0 has
already been visited, we visit 2 instead.
Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the back of the queue and visit
3, which is at the front of the queue.
Only 4 remains in the queue since the only adjacent node of 3 i.e. 0 is already visited. We visit it.
Depth-first search
Depth-first search always expands the deepest node in the current frontier of the search tree.
The search proceeds immediately to the deepest level of the search tree, where the nodes have
no successors.
As those nodes are expanded, they are dropped from the frontier, so then the search ―backs up‖
to the next deepest node that still has unexplored successors.
The depth-first search algorithm is an instance of the graph-search algorithm;
Whereas breadth-first-search uses a FIFO queue, depth-first search uses a LIFO queue.
A LIFO queue means that the most recently generated node is chosen for expansion.
This must be the deepest unexpanded node because it is one deeper than its parent—which, in
turn, was the deepest unexpanded node when it was selected.
As an alternative to the GRAPH-SEARCH-style implementation, it is common to implement
depth-first search with a recursive function that calls itself on each of its children in turn.
Completeness: DFS search algorithm is complete within finite state space as it will expand
every node within a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the
algorithm. It is given by:
T(n)= 1+ n2+ n3 +.........+ nm=O(nm)
Where, m= maximum depth of any node and this can be much larger than d (Shallowest solution
depth)
Space Complexity: DFS algorithm needs to store only single path from the root node, hence
space complexity of DFS is equivalent to the size of the fringe set, which is O(bm).
Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or
high cost to reach to the goal node.
Advantage:
o DFS requires very less memory as it only needs to store a stack of the nodes on the path
from root node to the current node.
o It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right
path).
Disadvantage:
o There is the possibility that many states keep re-occurring, and there is no guarantee of
finding the solution.
o DFS algorithm goes for deep down searching and sometime it may go to the infinite
loop.
Example
Consider a graph with 5 vertices as shown below
We start from vertex 0, the DFS algorithm starts by putting it in the Visited list and putting all its
adjacent vertices in the stack.
Next, we visit the element at the top of stack i.e. 1 and go to its adjacent nodes. Since 0 has
already been visited, we visit 2 instead.
Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the top of the stack and visit it.
After we visit the last element 3, it doesn't have any unvisited adjacent nodes, so we have
completed the Depth First Traversal of the graph.