Professional Documents
Culture Documents
Chapter 2 Problems and Searching
Chapter 2 Problems and Searching
Chapter 2 Problems and Searching
Intelligent system:
Intelligent system is a system that shows a type of knowledge.
Agent:
An agent is something that sees (perceives) and acts accordingly.
Types of Agents:
1. Human Agent
2. Robotics agent
3. Software agent
Que-2: What is problem? What is problem solving? Explain general algorithm of problem
solving.
Problem:
Problem is a question to be solved.
Problem Solving:
Problem solving is the analysis of how computer is used to find solutions in specific domains.
Problem solving is defined as the way where an agent finds a sequence of actions to achieve
the goal. A good example of problem is “ Tower of Hanoi”.
Que-3: What is the Tower of Hanoi? How to solve Tower of Hanoi puzzle? Explain it with 3
disk example.
The Tower of Hanoi is a mathematical puzzle comprising three rods and numerous
disks placed one over the other.
It is also known as the Tower of Brahma or the Lucas tower, as the French
mathematician Edouard Lucas introduced it back in 1883.
This puzzle has three rods and a variable number of stacked disks. Those rods are
designed as cyclic towers. So, the larger disks in diameter are stacked on the bottom,
and the smaller disks are stacked on top.
Initially, we are given three pegs or rods. And one of them (A, shown in the example)
has all the disks stacked. We aim to move an entire stack of disks from one rod (A) to
another (C) by obeying some specific rules.
Here is the initial setup of the puzzle-
The initial state of this puzzle, all the disks will be stacked in rod one.
The final state is all those disks from rod one will be stacked upon rod two or rod
three.
We can move an on-disk from one rod to another at any given time.
We can only move the uppermost disk from the rod.
A disk can’t be placed over another disk, which is smaller.
We will have a Tower of Hanoi setting of n disks would cost (2n – 1) move.
Note: Though we can only move one disk at a time, it breaks our problem from a 3-disk
problem to a 2-disk problem, which is a recursive call.
Step 2) As we call a recursive call from peg A and the destination is peg B, we will use peg C
as a helper.
Now we need to move n-1 or one disk from source to helper, moving the smallest disk from
peg A to peg C.
At this stage: Source = peg A
Destination = peg B
Helper = peg C
Step 3) Then, according to our algorithm, the nth or 2nd disk needs should be transferred
into the destination or peg B.
Step 4) Now, we will move the n-1 disks or disk one from helper or peg C to the destination
or peg B according to the third stage of our algorithm.
Step 5) After completing the recursive call, we will return to our previous setting when the
first stage of the algorithm.
Step 6) Now, in the second stage, we will move our source to our destination, which is moving
disk 3 to peg C from peg A.
task is to move the remaining disks from helper (peg B) to destination (peg C). We will use the
initial source or peg A as a helper in this case.
Step 8) As we can’t move two disks simultaneously, we will call a recursive call for disk 1.
According to the last step and our algorithm, a destination in this step is peg A.
Step 9) Our recursive call is completed now. Then we move disk 2 from its source to its
destination.
Step 10) Then we move our remaining n-1 or disk 1 from helper to destination.
At this stage:Source = peg A
Destination = peg C
Helper = peg B
Que-4: Explain Water Jug Problem in Artificial Intelligence using tree diagram.
Water Jug Problem:
There are two jugs of volume A litre and B litre. Neither has any measuring mark on
it. There is a pump that can be used to fill the jugs with water. How can you get
exactly x litre of water into the A litre jug. Assuming that we have unlimited supply of
water.
Note: Let's assume we have A=4 litre and B= 3 litre jugs. And we want exactly 2 Litre
water into 4 litre jug A.
Solution:
Initialization:
(4,0) (0,3)
Que-5: Explain various possible states in water jug problem with two jugs having capacity 4
litre and 3 litre.
(4,Y)
1 (X,Y | X<4)
{Fill 4-gallon jug}
(X,3)
2 (X,Y |Y<3)
{Fill 3-gallon jug}
(0,Y)
3 (X,Y |X>0)
{Empty 4-gallon jug}
(X,0)
4 (X,Y | Y>0)
{Empty 3-gallon jug}
Rule State Process
(4,Y-(4-X))
5 (X,Y | X+Y>=4 ^ Y>0)
{Pour water from 3-gallon jug into 4-gallon jug until 4-gallon jug is full}
(X-(3-Y),3)
6 (X,Y | X+Y>=3 ^X>0)
{Pour water from 4-gallon jug into 3-gallon jug until 3-gallon jug is full}
(X+Y,0)
7 (X,Y | X+Y<=4 ^Y>0)
{Pour all water from 3-gallon jug into 4-gallon jug}
(0,X+Y)
8 (X,Y | X+Y <=3^ X>0)
{Pour all water from 4-gallon jug into 3-gallon jug}
(2,0)
9 (0,2)
{Pour 2 gallon water from 3 gallon jug into 4 gallon jug}
Que-6: There are two water jugs with capacity 3 litre and 5 litre. Explain all the steps to
transfer 4 litre water in 5 litre jug.
AI Technique Knowledge
General Technique Data
base base
Solution
Solution
There are two types of search strategy used to solve the problem in artificial intelligence.
1. Uninformed search / Blind search strategy
2. Informed search strategy / Heuristics search
There are main two types of uninformed searching or brute force searching.
a. Breadth First Search (BFS)
b. Depth First Search (DFS)
In DFS, instead of going on width, one branch of root node or tree is explored
one by one until the goal state is found.
DFS explores each possible paths to find the solution.
DFS requires less memory.
Amount of time required is decreased.
DFS can be trapped by following unfaithful path.
No minimal solution is guaranteed by DFS.
Que-10: Solve Following Tree example using BFS and DFS techniques. A is the initial state
and G is the Goal state.
Step:5 Check out about the goal. Here G is the Goal state so stops there and exit.
Step-2: depth of root node A is generated. (Only the leftmost child of root node A is generated
which is B.)
Step-5: depth of node I is not generated. So backtrack to node B and generate the
depth. (node F)
‘]
Que-11: Give the differences between BFS and DFS searching techniques.
BFS DFS
1 It is Breadth First Search It is Depth First Search
2 It uses Data structure Queue. It uses data structure stack.
3 It requires more memory space. It requires less memory space.
4 It is time consuming. It optimizes the time.
5 It uses FIFO policy to search the goal It uses LIFO policy to search the goal.
6 It search path by traversing It search path by traversing vertical first
horizontal first and vertical next. and horizontal next.
7 It doesn’t uses backtracking. It uses backtracking.
Que-12: Explain a Hill Climbing Algorithm? Also explain state space diagram.
State and value make up the two components of a hill climbing algorithm node.
Local maximum:
A local maximum is a solution that surpasses other neighbouring solutions or states
but is not the best possible solution.
Global maximum:
This is the best possible solution achieved by the algorithm.
Current state:
This is the existing or present state.
Shoulder:
This is a plateau whose edge is stretching upwards.