AI Assignment 008
AI Assignment 008
Session 2020-2022
Assignment of AI
Q4. Explain Depth first Search and Breadth first search with example?
A4.
S.No. BFS DFS
1. BFS stands for Breadth First Search. DFS stands for Depth First Search.
2. BFS(Breadth First Search) uses DFS(Depth First Search) uses Stack
Queue data structure for finding the data structure.
shortest path.
3. BFS is more suitable for searching DFS is more suitable when there are
vertices which are closer to the given solutions away from source.
source.
4. BFS considers all neighbours first DFS is more suitable for game or
and therefore not suitable for puzzle problems. We make a
decision making trees used in games decision, then explore all paths
or puzzles. through this decision. And if this
decision leads to win situation, we
stop.
5. The Time complexity of BFS is O(V The Time complexity of DFS is also
+ E) when Adjacency List is used O(V + E) when Adjacency List is
and O(V^2) when Adjacency Matrix used and O(V^2) when Adjacency
is used, where V stands for vertices Matrix is used, where V stands for
and E stands for edges. vertices and E stands for edges.
6. Here, siblings are visited before the Here, children are visited before the
children siblings
Q6. What are Hill climbing & Branch and Bound technique?
A6. Hill-climbing searches work by starting off with an initial guess of a
solution, then iteratively making local changes to it until either the solution is
found or the heuristic gets stuck in a local maximum. There are many ways to
try to avoid getting stuck in local maxima, such as running many searches in
parallel, or probabilistically choosing the successor state, etc. In many cases,
hill-climbing algorithms will rapidly converge on the correct answer. However,
none of these approaches are guaranteed to find the optimal solution.
Branch-and-bound solutions work by cutting the search space into pieces,
exploring one piece, and then attempting to rule out other parts of the search
space based on the information gained during each search. They are guaranteed
to find the optimal answer eventually, though doing so might take a long time.
For many problems, branch-and-bound based algorithms work quite well, since
a small amount of information can rapidly shrink the search space.
Q7. Explain with suitable example Best first search and A* algorithm.
A7. In BFS and DFS, when we are at a node, we can consider any of the
adjacent as next node. So both BFS and DFS blindly explore paths without
considering any cost function. The idea of Best First Search is to use an
evaluation function to decide which adjacent is most promising and then
explore. Best First Search falls under the category of Heuristic Search or
Informed Search.
We use a priority queue to store costs of nodes. So the implementation is a
variation of BFS, we just need to change Queue to Priority Queue.
A* Search algorithm is one of the best and popular technique used in path-
finding and graph traversals. Informally speaking, A* Search algorithms, unlike
other traversal techniques, it has “brains”. What it means is that it is really a
smart algorithm which separates it from the other conventional algorithms.
This fact is cleared in detail in below sections.
And it is also worth mentioning that many games and web-based maps use this
algorithm to find the shortest path very efficiently (approximation).
Explanation
Consider a square grid having many obstacles and we are given a starting cell
and a target cell. We want to reach the target cell (if possible) from the starting
cell as quickly as possible. Here A* Search Algorithm comes to the rescue.
What A* Search Algorithm does is that at each step it picks the node according
to a value-‘f’ which is a parameter equal to the sum of two other parameters –
‘g’ and ‘h’. At each step it picks the node/cell having the lowest ‘f’, and process
that node/cell.
We define ‘g’ and ‘h’ as simply as possible below
g = the movement cost to move from the starting point to a given square on the
grid, following the path generated to get there.
h = the estimated movement cost to move from that given square on the grid to
the final destination. This is often referred to as the heuristic, which is nothing
but a kind of smart guess. We really don’t know the actual distance until we
find the path, because all sorts of things can be in the way (walls, water, etc.).
There can be many ways to calculate this ‘h’ which are discussed in the later
sections.
If two or more positive literals (or two or more negative literals) in clause are
unifiable and is their most general unifier, then is called a factor of . For
example, is factored to . In such a
factorization, duplicates are removed.
Let and be two clauses with no variables in common, let contain a
positive literal , contain a negative literal , and let be the most general
unifier of and . Then
----------
∴P v Q
P^Q P^Q
---------- OR ----------
∴P ∴Q
P->Q
-----------
∴Q
4) Modus Tollens: This rule states that:
P->Q
~Q
-----------
∴~P
P->Q
-----------
∴Q
P->Q
-----------
∴P
PvQ
~P^R
-----------
∴Q v R
8) Hypothetical Syllogism: This rule states the transitive relation between the
statements:
P->Q
Q->R
-----------
∴P->R
PvQ
~P
-----------
∴Q
A Horn clause with exactly one positive literal is a definite clause or a strict
Horn clause;a definite clause with no negative literals is a unit clause, and a
unit clause without variables is a fact;. A Horn clause without a positive literal
is a goal clause. Note that the empty clause, consisting of no literals (which is
equivalent to false) is a goal clause. These three kinds of Horn clauses are
illustrated in the following propositional example:
Type of Disjunction
Implication form Read intuitively as
Horn clause form
assume that,
Definite ¬p ∨ ¬q ∨ ... ∨
u ← p ∧ q ∧ ... ∧ t if p and q and ... and t all
clause ¬t ∨ u
hold, then also u holds
assume that
Fact u u ← true
u holds
show that
¬p ∨ ¬q ∨ ... ∨ false ← p ∧ q ∧ ...
Goal clause p and q and ... and t all
¬t ∧ t
hold
A14. Frame, in Artificial Intelligence (AI), is a data structure used to divide
knowledge into substructures by representing “stereotyped situations”. Frames
are the primary data structure used in Frame Language. Frames are also an
extensive part of knowledge representation and reasoning schemes.
Property inheritance
Depending upon how the parse tree is built, parsing techniques are classified
into three general categories, namely, universal parsing, top-down parsing,
and bottom-up parsing. The most commonly used parsing techniques are top-
down parsing and bottom-up parsing. Universal parsing is not used as it is not
an efficient technique.
Q16. What is Context Free Grammar, Recursive Transition Nets (RTN) and
Augmented Transition Nets (ATN)?
A16. Context free grammar is a formal grammar which is used to generate all
possible strings in a given formal language.
G= (V, T, P, S)
Where,
Q18. Explain Component of Planning Systems, Goal Stack Planning & Linear
planning with suitable example?
When a particular problem will be solved, at that time some specific rules
regarding to that problem are to be applied. Then apply the choosen rule to
compute the new problem state that arises from its application. Detect when a
solution has been found and calculate the active and inactive ends of that
problem. Various components of a planning system are described as follows.
(a) States: For a planning process, the planners decompose the world into some
environments. Then environments are defined by some logical conditions and
states. The problems can be viewed as the task of finding a path from a given
starting state to some desirable goal state. The state can be viewed as a
conjunction of positive literals. For example, Rich A famous might represent
the state of a best agent.
The expert system is a part of AI, and the first ES was developed in the year
1970, which was the first successful approach of artificial intelligence. It solves
the most complex issue as an expert by extracting the knowledge stored in its
knowledge base. The system helps in decision making for complex problems
using both facts and heuristics like a human expert. It is called so because it
contains the expert knowledge of a specific domain and can solve any complex
problem of that particular domain. These systems are designed for a specific
domain, such as medicine, science, etc.
Architecture:
Here, we will explain the working of an expert system by taking an example of
MYCIN ES. Below are some steps to build an MYCIN:
=========================================================