0% found this document useful (0 votes)
1 views17 pages

Algorithm

The document discusses two informed search algorithms: Best First Search (Greedy Search) and A* Search Algorithm. Best First Search selects the most promising node based on a heuristic function, while A* combines the cost to reach a node with the heuristic to find the shortest path efficiently. Additionally, it covers propositional logic, its syntax, logical connectives, and limitations.

Uploaded by

myhackingworldd
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)
1 views17 pages

Algorithm

The document discusses two informed search algorithms: Best First Search (Greedy Search) and A* Search Algorithm. Best First Search selects the most promising node based on a heuristic function, while A* combines the cost to reach a node with the heuristic to find the shortest path efficiently. Additionally, it covers propositional logic, its syntax, logical connectives, and limitations.

Uploaded by

myhackingworldd
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/ 17

1:59 .

,ml 4G -=:)•

In the informed search we will discuss two main


algorithms which are given below:

o Best First Search Algorithm(Greedy search)

o A* Search Algorithm

1.) Best-first Search Algorithm


(Greedy Search):
Greedy best-first search algorithm always selects the
path which appears best at that moment. It is the
combination of depth-first search and breadth-first
search algorithms. It uses the heuristic function and
search. Best-first search allows us to take the
advantages of both algorithms. With the help of
best-first search, at each step, we can choose the
most promising node. In the best first search
algorithm, we expand the node which is closest to
the goal node and the closest cost is estimated by
heuristic function, i.e.
I f(n )= g(n).

l.
Were, h(n)= estimated cost from node n to the goa

by
The greedy best first algorithm is implemented
the priority queue.

Best first search algorithm:

0 Ste p 1: Place the starting node into the OPEN


list.

o Ste p 2: If the OPEN list is empty, Stop and


return failure.

o Ste p 3: Remove the node n, from the OPEN


list which has the lowest value of h(n), and
places it in the CLOSED list.

o Ste p 4: Expand the node n, and generate the


successors of node n.

o Ste p 5: Check each successor of node n, and


find whether any node is a goal node or not. If
any successor node is goal node, then return
success and terminate the search, else
proceed to Step 6.

o Ste p 6: For each successor node, algorithm


checks for evaluation function f(n), and then
check if the node has been in either OPEN or
CLOSED list. If the node has not been in both
listI then add it to the OPEN list.

tec 7: Return to Step 2.


Particip,ate in Tech Aptitude Challenge 2022 and get
a chance to win Vouchers every Week.

~ TechGig-Geek Goddess 2022 Apply Now

o Best first search can switch between BFS and


DFS by gaining the advantages of both the
algorithms.

o This algorithm is more efficient than BFS and


DFS algorithms.

Disadvantages:

o It can behave as an unguided depth-first


search in the worst case scenario.

o It can get stuck in a loop as DFS.

o This algorithm is not optimal.


2:01 •• 4G 1• I•

2.) A* Search Algorithm:

A* search is the most commonly known form of best-


first search. It uses heuristic function h(n), and cost
to reach the node n from the start state g(n}. It has
combined features of UCS and greedy best-first
search, by which it solve the problem efficiently. A*
search algorithm finds the shortest path through the
search space using the heuristic function . This
search algorithm expands less search tree and
provides optimal result faster. A* algorithm is similar
to UCS except that it uses g(n)+h(n) instead of g(n).

In A* search algorithm, we use search heuristic as


well as the cost to reach the node. Hence we can
combine both costs as following, and this sum is
called as a fitness number.

JIQl(j!;
0
GEEi-Ci
GODDESS

Tech Aptitude Challenge 2022


Join the league of best women coders
So !vP thf>Sf' /5 ~-l((),:; ,;r-..~ gf"t ~ d1an(f>
t o w in Arn,l .:'nn v1·.l1d,,:-r' •• · •·· \ ·,,.-.,ek!

111 s,1nchrcn,
;:She Thelnnovator

Partic ipate in Tech Aptitude Challenge 2022 and get


a chance to win Vouchers every Week.

~ TechGig-Geek Goddess 2022 Apply Now

f(n) = g(n) + h(n)


-~·~ l
.-------.
~
-~ Cost to reach
I~ to ~each from node n to

◊!~~,, ~
A Portfolio of 20-25 Stocks
That Has Delivere~ 400°/~ ltt>
Sponsored ~~81•• . mg.com
Participate in Tech Aptitude Challenge 2022 and get
a chance to win Vouchers every Week.

~ TechGig-Geek Goddess 2022 Apply Now

Step 2: Check if the OPEN list is empty or not, if the


list is empty then return failure and stops.

Step 3: Select the node from the OPEN list which


has the smallest value of evaluation function (g+h), if
node n is goal node then return success and stop,
otherwise

Step 4: Expand node n and generate all of its


successors, and put n into the closed list. For each
successor n', check whether n' is already in the
OPEN or CLOSED list, if not then compute evaluation
function for n' and place into Open list.
example, we will traverse the given
the A* algorithm. The heuristic value
is given in the below table so we will c,
) of each state using the formula f (n)=
,here g(n) is the cost to reach any nod
tate.

ve will use OPEN and CLOSED list.

State h(
B
y "'._5 s
A ••
A Portfolio of 20-25 Stocks
'lL..,IICLJ That Has Delivered 400°/c
Propositional logic in Artificial
intelligence
Propositional logic (PL) is the sim ple
st for m of log ic
where all the statements are made
by pro po sit ion s. A
proposition is a declarative sta tem en
t wh ich is eit he r
true or false. It is a tec hn iqu
e of kn ow led ge
representation in logical and mathe
matical for m.

Example:

a) It is Sunday.
b) Th e Sun rises fro m We st (False pro
po sit ion )
c) 3+ 3= 7(False pro po sit ion )
d) 5 is a prime nu mb er.

Following are some basic fa ct s ab ou t


propositional logic:

ADV ERT ISE ME NT


■1 4G (L }

·opositional logic is also called Boolean logic


5 it works on Oand 1.

1 propositional logic, we use symbolic


1ariables to represent the logic, and we can

Jse any symbol for a representing a


proposition, such A, B, C, P, Q, R, etc.

Propositions can be either true or false, but it


cannot be both.

Propositional logic consists of an object,


relations or function, and l,ogical connectives.

These connectives are also called logical


operators.

, The propositions and connectives are the


basic elements of the propositional logic.

o Connectives can be said as a logical operator


which connects two sentences.
o A proposition formula which is always true is
called tauto logy , and it is also called a valid
sentence.
o A proposition formula whic h is always false is
called Cont radic tion.

o A proposition formula which has both true and


false values is called

o Statements which are questions, commands,


or opinions are not propositions such as
"Wh ere is Rohini", "How are you", "What is
your name", are not propositions.

Syntax of propositional logic :


The syntax of propositional logic defines the

allowable sentences for the knowledge

representation. There are two types of Propositions:

a. Atomic Propositions
b. Compound propositions

o Atomic Proposition: Atomic propositions are


the simple propositions. It consists of a single
proposition symbol. These are the sentences
which must be either true or false.

Example:

a) 2+2 is 4, it is an atomic proposition as it is a true 1


A Portfolio of 20-25 Stoc ks
That Has Delivered: ?~! ~ IG>
'

Example:

a) 2+2 is 4, it is an atomic proposition as it is a tl"iue 1


b) "The Sun is cold" is also a proposition as it is a fal

o Compound proposition: Compound


propositions are constructed by combining
simpler or atomic propositions, using
parenthesis and logical connectives.

Example:
6:44 ,,ml 4G u,

Logical Connectives:
Logical connectives are used to connect two simpler
propositions or representing a sentence logically. We
can create compound propositions with the help of
logical connectives. There are mainly five
connectives, which are given as follows:

1. Negation: A sentence such as -, P is called


negation of P. A literal can be either Positive
literal or negative literal.

2. Conjunction: A sentence which has "


connective such as, P " Q is called a
conjunction.
Example: Rohan is intelligent and
hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. ➔ PA Q.

3. Disjunction: A sentence which has v


connective, such as P v Q. is called
disjunction, where P and Q are the
propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so
we can write it as P v Q.

4. Implication: A sentence such as P ➔ Q, is


called an implication. Implications are also
known as if-then rules. It can be represented
as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet,
so it is represented as P ➔ Q
6:44 ., I1 4G U ·

< a www.javatpoint.com X

4. Implication: A sentence such as P ➔ Q, 1s


called an implication. Implications are also
known as if-then rules. It can be represented
as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet,
so it is represented as P ➔ Q

5. Biconditional: A sentence such as P~ Q is a


Biconditional sentence, example If I am
breathing, then I am alive
P= I am breathing, Q= I am alive, it can
be represented as P <=} Q.

Following is the summarized table for


Propositional Logic Connectives:

'
RRR
Connective symbols Word Technical term Example
Conjunction Al\8
Disjunction AV 8
A Portfolio of 20-25 Stocks
That Has Delivered 400o/~ [l>
1
www.researchandrankinq.com
AND Conjunction AIIB
OR Dlsjunc tlon AVB
Implies Implicat ion A➔ B
If and only If Blcondft lonal A= B
Not Negation ~Aor~B

Truth Table:

In propositional logic, we need to know the trutt


values of propositions in all possible scenarios. WE
can combine all the possible combination with logica
: onnectives, and the representation of thesE
~ombinations in a tabular format is called Trutt
able. Following are the truth table for all logica
:onnectives:

ForN-,atlon:

True False
False True

For Conjunction:

Q PAQ
rrue l True True
rue False False
alse t True False
alse False False

,r disjunction:

Q PVQ.
ue True True
lse True True
Je
se
I False
I False
ITrue
False

'Implication:

I? True
- - -- - -
True

lcondltional:
Truth table with three propositions:

We can build a proposition composing th1ree


propositions P, Q, and R. This truth table is made-up
of 8n Tuples as we have taken three proposition
symbols.

P Q R -, Pv Q -,
6:45 •• ~. 4G U ·
o Associativity:
o (P A Q) A R= P A (Q A R),

0 (P V Q) V R= p V (Q V R)

o Identity element:

o P A True = P,

o P v True= True.

o Distributive:
o PA (Q v R)=(P A O) v (P A R).

0 p V (Q /\ R) = (P V Q) /\ (P V R) .

o DE Morgan's Law:
0 -, (P /\ Q) = (-,P) V (-,Q)

0 -, (P V Q) = (-, P) /\ (-,Q).

o Double-negation elimination:

o -, (,P) = P.

Limitations of Propositional logic:

o We cannot represent relations like ALL, some,


or none with propositional logic. Example:

a. All the girls are intelligent.

b. Some apples are sweet.

o Propositional logic has limited expressive


power.

" 1n orooositional loaic. we cannot describe

You might also like