Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
16 views30 pages

AIML Module-01

.......,.................

Uploaded by

Vijaylaxmi Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views30 pages

AIML Module-01

.......,.................

Uploaded by

Vijaylaxmi Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Artificial Intelligence and Machine Learning (21CS54)

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.

Acting humanly: The Turing Test approach

 The Turing Test, proposed by Alan Turing (1950), was designed to provide a satisfactory
operational definition of intelligence.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 1


Artificial Intelligence and Machine Learning (21CS54)

 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.

Thinking humanly: The cognitive modeling approach


 If we are going to say that a given program thinks like a human, we must have some way of
determining how humans think.
 We need to get inside the actual workings of human minds. There are three ways to do this:
o Through introspection—trying to catch our own thoughts as they go by.
o Through psychological experiments—observing a person in action;
o Through brain imaging—observing the brain in action.
 If the program’s input–output behavior matches corresponding human behavior, that is evidence
that some of the program’s mechanisms could also be operating in humans.
 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 2


Artificial Intelligence and Machine Learning (21CS54)

 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.

Thinking rationally: The “laws of thought” approach


 The Greek philosopher Aristotle was one of the first to attempt to codify ―right thinking,‖ that is,
irrefutable reasoning processes. His syllogisms provided patterns for argument structures that
always yielded correct conclusions when given correct premises.
 For example, ―Socrates is a man; all men are mortal; therefore, Socrates is mortal.‖
 These laws of thought were supposed to govern the operation of the mind; their study initiated the
field called logic.
 Logicians in the 19th century developed a precise notation for statements about all kinds of objects
in the world and the relations among them.
 The so-called logicist tradition within artificial intelligence hopes to build on such programs to
create intelligent systems.
 There are two main obstacles to this approach.
o First, it is not easy to take informal knowledge and state it in the formal terms required
by logical notation, particularly when the knowledge is less than 100% certain.
o Second, there is a big difference between solving a problem ―in principle‖ and solving it
in practice.

Acting rationally: The rational agent approach


 An agent is just something that acts. Of course, all computer programs do something, but computer
agents are expected to do more: operate autonomously, perceive their environment, persist over a
prolonged time period, adapt to change, and create and pursue goals.
 A rational agent is one that acts so as to achieve the best outcome or, when there is uncertainty, the
best expected outcome.
 In the ―laws of thought‖ approach to AI, the emphasis was on correct inferences. Making correct
inferences is sometimes part of being a rational agent.
 On the other hand, correct inference is not all of rationality; in some situations, there is no provably
correct thing to do, but something must still be done.
 There are also ways of acting rationally that cannot be said to involve inference.
 All the skills needed for the Turing Test also allow an agent to act rationally. Knowledge
representation and reasoning enable agents to reach good decisions.
 The rational-agent approach has two advantages over the other approaches.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 3


Artificial Intelligence and Machine Learning (21CS54)

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.

THE FOUNDATIONS OF ARTIFICIAL INTELLIGENCE


The several aspects that are considered for the development of Artificial Intelligence are
Philosophy
1. Can formal rules be used to draw valid conclusions?
2. How does the mind arise from a physical brain?
3. Where does knowledge come from?
4. How does knowledge lead to action?
 Aristotle (384–322 B.C.), whose bust appears on the front cover of this book, was the first to formulate
a precise set of laws governing the rational part of the mind.
 He developed an informal system of syllogisms for proper reasoning, which in principle allowed one
to generate conclusions mechanically, given initial premises.
 Much later, Ramon Lull (d. 1315) had the idea that useful reasoning could actually be carried out by a
mechanical artifact.
 Thomas Hobbes (1588–1679) proposed that reasoning was like numerical computation, that ―we add
and subtract in our silent thoughts.‖
 The automation of computation itself was already well under way. Around 1500, Leonardo da Vinci
(1452–1519) designed but did not build a mechanical calculator; recent reconstructions have shown
the design to be functional.
 The first known calculating machine was constructed around 1623 by the German scientist Wilhelm
Schickard (1592–1635), although the Pascaline, built-in 1642 by Blaise Pascal (1623–1662), is more
famous.
 Pascal wrote that ―the arithmetical machine produces effects which appear nearer to thought than all
the actions of animals.‖
 Gottfried Wilhelm Leibniz (1646–1716) built a mechanical device intended to carry out operations on
concepts rather than numbers, but its scope was rather limited.
 Leibniz did surpass Pascal by building a calculator that could add, subtract, multiply, and take roots,
whereas the Pascaline could only add and subtract.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 4


Artificial Intelligence and Machine Learning (21CS54)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 5


Artificial Intelligence and Machine Learning (21CS54)

 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,‖

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 6


Artificial Intelligence and Machine Learning (21CS54)

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,

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 7


Artificial Intelligence and Machine Learning (21CS54)

(2) the representation is manipulated by cognitive processes to derive new internal


representations, and
(3) these are in turn retranslated back into action.
 Workshop in September 1956 at MIT:
 George Miller presented The Magic Number Seven (It is often interpreted to argue that the number
of objects an average human can hold in short-term memory is 7 ± 2. This has occasionally been
referred to as Miller's law.)
 The second cognitive limitation Miller discusses is memory span. Memory span refers to the longest
list of items (e.g., digits, letters, words) that a person can repeat back in the correct order is only 50%
of trials immediately after the presentation
 Noam Chomsky presented Three Models of Language
 Allen Newell and Herbert Simon presented The Logic Theory Machine.
 These three influential papers showed how computer models could be used to address the psychology
of memory, language, and logical thinking respectively.
 "A cognitive theory should be like a computer program" (Anderson, 1980); that is, it should describe
a detailed information processing mechanism whereby some cognitive function might be
implemented.

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).

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 8


Artificial Intelligence and Machine Learning (21CS54)

 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.

HISTORY OF ARTIFICIAL INTELLIGENCE


Inception of Al (1943-1955)
 The first work that is now generally recognized as Al was done by Warren McCulloch and
Walter Pitts (1943)

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 9


Artificial Intelligence and Machine Learning (21CS54)

 They drew on three sources


o knowledge of the basic physiology and function of neurons in the brain;
o A formal analysis of propositional logic
o Turing's theory of computation.
 They proposed a model of artificial neurons in which each neuron is characterized as being "on"
or "off," with a switch to "on" occurring in response to stimulation by a sufficient number of
neighboring neurons.
 McCulloch and Pitts also suggested that suitably defined networks could learn. Donald Hebb
(1949) demonstrated a simple updating rule for modifying the connection strengths between
neurons.
 1950: Two UG students at Harvard, Marvin Minsky and Dean Edmonds, built the first neural
network called SNARC which used 3000 vacuum tubes and a surplus automatic pilot
mechanism from a B-24 bomber to simulate a network of 40 neurons.
 1950: Alan Turing stressed on computing machine and intelligence, where he introduced Turing
test, M/C learning, genetic algorithms, & reinforcement learning-It would be easy to create
human level Al by learning algorithms.
The birth of artificial intelligence (1956):
 McCarthy convinced Minsky, Claude Shannon, and Nathaniel Rochester to help him bring
together U.S. researchers interested in automata theory, neural nets, and the study of
intelligence. They organized a two-month workshop at Dartmouth in the summer of 1956. a
month, 10 man study of artificial intelligence be carried out during the summer of 1956 at
Dartmouth College in Hanover, New Hampshire
 An attempt was made to find how to make machines use language, form abstractions and
concepts, solve kinds of problems now reserved for humans, and improve themselves 1963
Microworlds.
 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.
 Daniel Bobrow's STUDENT program (1967) solved algebra story problems, such as the
following:
 If the number of customers Tom gets is twice the square of 20 percent of the number of
advertisements he runs, and the number of advertisements he runs is 45, what is the number of
customers Tom gets?
Early enthusiasm, great expectations (1952-1969)

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 10


Artificial Intelligence and Machine Learning (21CS54)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 11


Artificial Intelligence and Machine Learning (21CS54)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 12


Artificial Intelligence and Machine Learning (21CS54)

The return of neural networks


 In mid 1980 four groups reinvented the back propagation learning algorithms and were applied
on the many learning problems in CSE and psychology
 The widespread dissemination of these results in collection parallel distributed processing
caused great excitements. They have capability to learn from the examples.
 These connectionist models were competitors to the symbolic model proposed by newel and
simons and logistic approach of Mc-Carthy. As human manipulate symbols.
 These connectionists can compare the predicted true value to the expected output and can
modify their parameters to decrease the in differences.
Probabilistic reasoning and machine learning(1987-present)
 Brittleness to expert system lead to incorporation of new more scientific approach probability in
place of boolean logic
 Machine learning rather than hand coding , Experimental results rather than philosophical
claims.
 Soon UC Irvine was used as a standard repository for ML datasets, the international planning
competition for planning algorithms
 LibreSpeech corpus for speech recognition, The MNIST data set for handwritten digit
recognition ImageNet and COCO for image object recognition SQUAD for NLP answering.
 Hidden Markov model dominated the area of speech recognition during 1980 which is based on
the real, and large corpus of speech dataset to ensure the performance is robust.
 Note that there was no scientific claim that human use HMM but HMM provided mathematical
framework for understanding and solving the problems.
 1988 was important year for connection between the Al and other fields like statistics, OR,
decision theory, and control systems
 Pearl's probabilistic reasoning in intelligent systems lead to new acceptance of probability and
decision theory in Al.
 Pearl's Baysian networks yielded the rigorous and efficient formalism for representing uncertain
knowledge as well as practical algorithms for probabilistic reasoning.
 Rich sutan's reinforcement learning was the major contribution in 1988.
Big Data (2001-present)
 Advent of www and advancements in computing power facilitated the creation of very large data
sets called (volume, velocity, verities)
 Big data: which includes trillions of words of text, billions of images and billions of hours of
speech and video, vast amount of genomic data, vehicle tracking data, social networking data.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 13


Artificial Intelligence and Machine Learning (21CS54)

 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

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 14


Artificial Intelligence and Machine Learning (21CS54)

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.

Well-defined problems and solutions


A problem can be defined by five components:
1. INITIAL STATE:
 The initial state that the agent starts in.
2. ACTIONS:
 A description of the possible actions available to the agent.
 Given a particular states, ACTIONS(s) returns the set of actions that can be executed in s.
 Each of these actions is applicable in s.
3. TRANSITION MODEL:
 A description of what each action does is known as the transition model.
 A function RESULT(s,a) that returns the state that results from doing action a in state s.
 The term successor to refer to any state reachable from a given state by a single
 The state space of the problem is the set of all states reachable from the initial state by any
sequence of actions.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 15


Artificial Intelligence and Machine Learning (21CS54)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 16


Artificial Intelligence and Machine Learning (21CS54)

 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.

The complete state space is shown in Figure.

 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

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 17


Artificial Intelligence and Machine Learning (21CS54)

 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:

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 18


Artificial Intelligence and Machine Learning (21CS54)

 States: Any arrangement of 0 to 8 queens on the board is a state.


 Initial state: No queens on the board.
 Actions: Add a queen to any empty square.
 Transition model: Returns the board with a queen added to the specified square.
 Goal test: 8 queens are on the board, none attacked.
In this formulation, we have 64 · 63 ··· 57 ≈ 1.8 × 1014 possible sequences to investigate. A better
formulation would prohibit placing a queen in any square that is already attacked.
 States: All possible arrangements of n queens (0 ≤ n ≤ 8), one per column in the leftmost n
columns, with no queen attacking another.
 Actions: Add a queen to any square in the leftmost empty column such that it is not attacked by
any other queen.
This formulation reduces the 8-queens state space from 1.8 × 1014 to just 2,057, and solutions are easy
to find.

4. DONALD KNUTH PROBLEM


Our final toy problem was devised by Donald Knuth (1964) and illustrates how infinite state spaces
can arise. Knuth conjectured that, starting with the number 4, a sequence of factorial, square root, and
floor operations will reach any desired positive integer.

The problem definition is very simple:


 States: Positive numbers.
 Initial state: 4.
 Actions: Apply factorial, square root, or floor operation (factorial for integers only).
 Transition model: As given by the mathematical definitions of the operations.
 Goal test: State is the desired positive integer.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 19


Artificial Intelligence and Machine Learning (21CS54)

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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 20


Artificial Intelligence and Machine Learning (21CS54)

 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.

Traveling Salesperson Problem (Tsp)


 The traveling salesperson problem (TSP) is a touring problem in which each city TRAVELING
SALESPERSON PROBLEM must be visited exactly once.
 The aim is to find the shortest tour. The problem is known to be NP-hard, but an enormous
amount of effort has been expended to improve the capabilities of TSP algorithms.

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.

SEARCHING FOR SOLUTION


 A solution is an action sequence, so search algorithms work by considering various possible
action sequences.
 The possible action sequences starting at the initial state form a search tree with the initial state
at the root; the branches are actions and the nodes correspond to states in the state space of the
problem.
 The root node of the tree corresponds to the initial state.
 The first step is to test whether this is a goal state.
 Then we need to consider taking various actions. By expanding the current state; that is,
applying each legal action to the current state, thereby generating a new set of states. The parent
node leading to new child nodes.
 Leaf node, is a node with no children in the tree. The set of all leaf nodes available for expansion
at any given point is called the frontier. It is also called as open list.
 The process of expanding nodes on the frontier continues until either a solution is found or there
are no more states to expand.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 21


Artificial Intelligence and Machine Learning (21CS54)

The general TREE-SEARCH algorithm is shown.

function TREE_SEARCH (problem) returns a solution, or failure


Initialize the frontier using the initial state of problem
loop do
if the frontier is empty then return failure
choose a leaf node and remove it from the frontier
if the node contains a goal state then return the corresponding solution expand the
chosen node, adding the resulting nodes to the frontier.

 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.

Infrastructure for search algorithms


Search algorithms require a data structure to keep track of the search tree that is being constructed.
For each node n of the tree, we have a structure that contains four components:
 n.STATE: the state in the state space to which the node corresponds;
 n.PARENT: the node in the search tree that generated this node;
 n.ACTION: the action that was applied to the parent to generate the node;
 n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to the
node, as indicated by the parent pointers.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 22


Artificial Intelligence and Machine Learning (21CS54)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 23


Artificial Intelligence and Machine Learning (21CS54)

o INSERT(element, queue) inserts an element and returns the resulting queue.


 Queues are characterized by the order in which they store the inserted nodes.
 Three common FIFO QUEUE variants are the first-in, first-out or FIFO queue, which pops the
oldest element of the queue;
 LIFO QUEUE the last-in, first-out or LIFO queue (also known as a stack), which pops the
newest element
 PRIORITY QUEUE of the queue; and the priority queue, which pops the element of the queue
with the highest priority according to some ordering function.

Measuring problem-solving performance


 We can evaluate an algorithm’s performance in four ways:
o COMPLETENESS: Is the algorithm guaranteed to find a solution when there is one?
o OPTIMALITY: Does the strategy find the optimal solution, as defined on page 68?
o TIME COMPLEXITY: How long does it take to find a solution?
o SPACE COMPLEXITY: How much memory is needed to perform the search?
 Time and space complexity are always considered with respect to some measure of the problem
difficulty.
 In theoretical computer science, the typical measure is the size of the state space graph, |V | + |E|,
where V is the set of vertices (nodes) of the graph and E is the set of edges (links).
 In AI, the graph is often represented implicitly by the initial state, actions, and transition model
and is frequently infinite.
 For these reasons, complexity is expressed in terms of three quantities: b, the branching factor
or maximum number of successors of any node; d, the depth of the shallowest goal
 DEPTH node (i.e., the number of steps along the path from the root); and m, the maximum
length of any path in the state space.
 Time is often measured in terms of the number of nodes generated during the search, and space
in terms of the maximum number of nodes stored in memory.
 The search cost—which typically depends on the time complexity but can also include a term
for memory usage
 The total cost, which combines the search cost and the path cost of the solution found.

UNINFORMED SEARCH STRATEGY


 Uninformed search is also called blind search.
 The term means that the strategies have no additional information about states beyond that
provided in the problem definition.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 24


Artificial Intelligence and Machine Learning (21CS54)

 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

function BREADTH-FIRST-SEARCH(problem) returns a solution, or failure


node a node with STATE = problem. INITIAL-STATE, PATH-COST = 0
if problem.GOAL-TEST(node.STATE) then return SOLUTION(node)
frontiera FIFO queue with node as the only element
explored  an empty set
loop do
if EMPTY?(frontier) then return failure
node -POP(frontier)
add node.STATE to explored
for each action in problem.ACTIONS(node.STATE) do
childCHILD-NODE(problem, node, action)
if child.STATE is not in explored or frontier then

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 25


Artificial Intelligence and Machine Learning (21CS54)

if problem.GOAL-TEST(child.STATE) then return SOLUTION(child)


frontier INSERT(child, frontier)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 26


Artificial Intelligence and Machine Learning (21CS54)

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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 27


Artificial Intelligence and Machine Learning (21CS54)

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;

function GRAPH-SEARCH(problem) returns a solution, or failure


initialize the frontier using the initial state of problem
initialize the explored set to be empty
loop do
if the frontier is empty then return failure
choose a leaf node and remove it from the frontier
if the node contains a goal state then return the corresponding solution
add the node to the explored set
expand the chosen node, adding the resulting nodes to the frontier
only if not in the frontier or explored set

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 28


Artificial Intelligence and Machine Learning (21CS54)

 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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 29


Artificial Intelligence and Machine Learning (21CS54)

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.

Prepared by Ms. Shilpa, Assistant Professor, Dept. of CSE, NCEH 30

You might also like