0% found this document useful (0 votes)
13 views16 pages

Search Algorithms Overview

Uploaded by

darsh.24bce11507
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)
13 views16 pages

Search Algorithms Overview

Uploaded by

darsh.24bce11507
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

Nane- Sudhomshu andey

Beg no':- 248Alo216


Module 2
Woksheet -4

DaThey den't tize any addton al infosmation ab out the


pstobem.
Rlgothm
G G Geedy - Best -Fiast Seaorch
W) a) Maiining a balan ce between infot maive ness ad cemputatorel
cost,
5) (b) weuistic
G) c) Any funchion witt a bettest guess
la) in Pax Algoaithm
t8) (a) Finding a Styategy at max jmizes the expeded cumulative
ewad.
a) a) A measue Cnumesical) o the desiabiity o gormes states
fog the AL,
Cnegdhve intinity)
Wosshe et 2

Seatch
t3) Tes1minal
Sfecustsiye
(5) Belet State
Mach the fo llouing
6)
’ This stavch algoitm erplbses the sh allouest
no des in the Soetch space befaye moving on to
deepes nedes
) w0 ctimbing. () Alocal somch algosith nthat iteycey moes
in he disecton of inc e0aing elevation in tte
solstion Space,
’ Te ptocess af eliminding bslanches orem the
seaich twee Canot affect tie find de cis on,
) Minmax Algoihm >(E An agositrn doH deci sion - aking in tuo
playe games to minimize the possible doss.
S) Lo cod Mioimun (c) A stte in the seatch space whese no
neighb outing states Bave a Aghe vale
Date

Waskshect-3 Page

Alpha
Stot t the soot nodo () :'s a max nocke
Move to 6 ond then to 02E
The value lam o's childen asd ae 3ond 55 amd
ond since His
MasOode Beta fos Bis updated to 5,
The values todt ok E's chbdsen aHe S and9 amd since it `
node The volve ol Eis 2. No since
47s & 67s, wp wil pune the sest sf the bianch as the conditen
OD
CD Move to C
C and then to F ,
O The valves sl F's chiten ce 1 k2 and since it is in
a maxmum no de, then the yalue wil be 2,
will be Peta
2 Peta fosl is
update d to 2,
(5ehe volue oe G's chiden ae 0 , Since itlsa moxinnum
node the value e Gis 0, Beta fos C Hemain.s 2,since 0à
Smalles than 2 valve fo C in 0.

The valoe fos 8is S


5 and the value fog Cis Q. Since A
no de
Date
Pege

Pouned Nodes:
The second chil d of node fa H)

e Tine Complexity
wtaut ptuning the time complety of sf a imax SeYCh
k deptB dis oC6)
in atee with bianching lacto9 6best-caLe scenastib (wits
lWith adp ha- beta_poning, in the seduced to or6
opiml puning)he time complewity Ca) be
effe cthiuely cuting the" bstanching facta in half
|Thos, the time cemplexity fox this toee, afte applying alpha
wo uld be oC6)whege b is tte bsaehi'ne
beta p9 uning,
facto C2 Bee),_gmd d Is thetoo2) deph (3). T5eYefose,
stedu ced e o(2 o)
the tinne compleity is
wblch Simputes to aoUnd o(2.83)
Date
Page

2
Salesman
Foblem (TSp) inuolves findng the shasttest possible sovta to
Uislt a set of cities exactly once and IetuHn to the
sterting city
E Ste Reptes entahioni
Bo TSe
TSP, astak is defined asa specifc tas 0H peimstaton
ef he cities, S4 areHe pyesens a Complete ouk wheye each
city is visited er actly oDEe
Exannple Suppose theste ate Scities A.6.c, D,E, a possible
state C tou) could be te Ae Se nted asi
A’8(>0’E’A

he ohjectve Functon:
The ohjclue funton meayuies the tstal dl'stonce Cas
Co cost)
ofa giuen tous, n H clinbing, he goal is t miimize this
functlen, which in TSP is tte totl lergth of tte tocs.
Exonmple;- to the tounCA’ßCpEA)thé ob jective tuncton
wpuld stabedáte caleulte he sum of the distance between
-8, 8-C, a C-0, 0-E, E-A.

The initial selotion is a odor 09 4ror heutistie- based


petmotatlon the cities to stot
Date
Poge

Etamle: <yoo Aave cites A,8,c,D,E you might gondomly


Qenetote an intial soluton ike:
his is the staen tingpoint' om which Hile chimbing wil tuy
to imptove the solstion.
Generion e Neighboushood of aState:
The neigh boushood ok a state cen sists f al the possiblo
Solotions (touss) tho can be Heached luom the csmen
(
stae by making smll chonges Ctoeal moes)
fos TS P. 0ne comm on wag te geneste neizh bou s by
swpping tuo cities jo he tou
neigh bau#
bous could be geneyated by swapping ckE1esutingini
Each swap pto ducese new tou4 in tho nelgh bouyhood
HQL Climbing Itesathon:
3n each #es tenton H) Cabing evalutes he ohjectie
function foy the cusRAt state and compa as it wtwith the
staes in neighbosI hocd.
The algoaithm selects the nelghboU}! wth he best objetiue
betoy thon he cuolestt stete.
Date
Page

Exomple:
C09//ent Stoe-(A’ (8E ’0>A), obiective functon 2so

fieighbonyState:- CAE’ B20) ohiechve stoncton 22ohm


"Since 22oKmjs- bettey than 250 Km, he al go31thm ioves to
the peighboug state
Condition fos Testninahon
Ihe Hll Cnbing Algoith n teaminates when no ketes
oeigh bout exzist mtaning %e cuggent state tas ea lowey obete
functlon thon all olits nei_hbeuy CAocal opimum),
othes poSc;ble temination conditiong:
’4fized no' of itesatjons fas been teactad,
’ he solution asn't impoved oves Cestan
The tme nnt ost ececuton has exeee ded
Ecarnple- 34 afte Sevegal itet ations, no ne of the neighbowing
states_ has abettes o hyèctive fun cton the algouth m widl
stop ajsuming he cuYent state is the best solotion.
lo

2 +2 4

30) +3 +6 >lo

Step by - Step Poo ceS I


O Stathihg node S
o Ccot fo each Sis o)
5 CRe9histte eshnate to
Fs)
Passible next node AC
-Move to node A
s)+ cest( S,A) = 0+|=|
ACe) > 3 ( teusisi c estimate to G G
fCA) = 9C0) +Aa) 3zY forom )
Possible neyt neder gkC
Move to nod C:
) cogt CAc)
4c)
Fc)
2 Ctheuistie
glc)
estimate to G romc)
+4Cc)=2+2=Y.
Possi ble nert node s- 0
Move to node h(fom C)
9CG) (c)
" AcG) o (becose G is the go al )
a(G) + 4(G) = 6+o -6
Path fo Un d:- t o0hinal Path is ( 2 6 with a toal castoe
6.

Time omple i':


The tine cengplerity of A* algospthm is genetoly oC6 whese,
b is the bopnching factox
d is the depth fof the solton.
elation.
(Y- hey components of PHoblem Fomcontiguyticon of the
OInitial State Stotng pointof the
pto blem Cinital aiangement of the titles),
) Goal Stote :- his spectties the desysed outo mes on toget contiguation
Cag Wan gement of les in the cles jate d tinal consigusydt ipo)
opees Aetions o4o moves hat can be pesytosymed to to an giton
oyom one stae to amoteg
DPatt cast This fun ctior asSign a numetical vale to each patho
seguence of aetons, t meaauste the cast o etiost
asseci dtad wih eachmg a pastieuloy statefyomte
initlstte.
SUECBssos tuncion i his duncton genegtes the pos| ble
SUCCeSSO s lom the
a glvern stte by appying
quai dabke epet atos,
fstoblen do gmblation o y the Eigtt tile puz2ey
"gnitialze:- The given aytangenment iles tn the stoting contis
atlon,
Ghoal State,- The desised cgtang emeat ef tiles in the tinal
condg usaton.
Opesatos- süding-p the bank Hle to an edyac ent
spate Cvp, do wn, Jeoy tigh).
"feth cost The no' mo ves taken to 9Ye ach a state faom te

Succes o functoo Gen-tetots Genetaes allpessible asonpemert


tle s alte idng the blank tide to an
adjacent érmpty space.

Unidom-(ost Seochi
Espands jo des bosed on tfhe j9t accumu lted pth cost.
Psties tize odes aith 4te lovest table cast fom tte
node stating
Gosortos to ind the shotest pth (9n tesm3 af path cost)
1f one exists,

Bsiea dth-fist SeaMch:


Erpurads podes evel by level
Ptiestize roder bosed on ttejsy the stortig
node
Find the s hosttest path it it exist
) Depth- Fiast Stec h:
possihle along abtanch be fote
Exploes ad deeply u
backtyac king (LIFO)
"Pshogtize Nodes based on
"May net ind te otim al seluton, but can be mote etioss
ethaen
in tems e memott memoy usage,
-"BFS soluton e te given gph

12

Best- sistt seanch um not be applied o tis


volues aHe not pto vlded . We donst Know he gaoh as he ustic
tost corn't be certaìn, esttmate d path
we'vp the path S’c CensideringH the patf fom t 40
with a Cost
in9 BFS.
Date
Page

6 Al¡csithm dogy Tic -Tae -Toe


Onitioaise the gome bocetok
gid with empty cell
asi4n too phye x and y

O Display the gome basc


"AfteM puesy move display the cuent state af the ganne
boctd sheuing empty and occupied cell
GBegin fl Pleye Tuns:
Sstaot with amd altest nate tunS blw the
2play es.
(0) Check fo win Condi tion'
Aftey evey moVe ocheck if the cu9Kentlyey kad
Win
column full mostKed=Win
diagonaly ful ma hed= Win
Chech fog dyaw Con dtiorr
92 the boatd is tuleie. al celly ate ocCäp ied no
one fos won) declole the gane as diaw.

(End gome/ Restat / Quit


9f aplayesH wjns. di's plhy the ineH anad te end
Date
Page

tsa cbyau, display the diay messag e and end the gane
a Gnive playe% a chance to qut o% to gestert (by suitching.
theist valves),

ens) Backtsiacking- sea ch Alqoithmi


O9nitalize;- Cyeate q 99 mat 9ist to ote [Link] he shadeo
Sudo Ko gid (62 he matx wih the inital values given)
Ü findepty cella r SeaHch fos arn emgty cel in the oimaste.
no empty cell i's sodnmed found, the pozzde is selved
(3 Toy numbess - fost each umbet 1 to 9
Check rt the nombey is valid,_place it din the cel!
Cdoesn't wiodate any sudoku yules.
the numbes is validplace itin the cell amd stecuy Sinely
tyy the backtac king nfuncten,.
" oheg i se enmove te -numbes plom the cell and contiue
taging otthesy nombe.
O Backtsa 9p no numbey can be placed in he cusYEN cel
9etuen false ( indicating_a fuoeto solve tAe pozzle).
this backttac King algoitm e teciuey solveS Sodeko
so puzles
by exploing diteyent _possibi'ties and b backtgach
when necess ay.
Pldeau Shoulde9
docal
alobal mai ma
Ridge

ines ises and tas ser tepsesenting ditfesent states


n the seaMch spare ,
Local aima is a peak ttat isn'+ tte fighest
Globa mascima is the Bigest peat.
" A patea is q flat egio n whee potogtor Atogtess Can be
made.
A Biàge is a nasyow , steep egon.
A shouldes migrt ever
iegion whe e sle piogess migtrt eventualy
Qoad to it's peak.
Wosst case tine complexity
algoi thm oCd)
b: bs an ching factosy Cavg no of soteesso4 nodes toa glvn
node )
d: depth of the shaowest sostion (Minimum no'of steps to
teach the goal)
in he cuent Case. A* sea/ch algo stittm might exploye evly
in tehe secokh space befose finding he solution,
possible path io

tWe sast case scenatio (Time complejty : o(6d)
b baonçhing facto91
d - depth the seco ch toee.
8FS algos/thmi
lbstst -cnse time com pleeity E: obd)
the evalvation duneton night not actuyately
auide the sensch towands the solstion , leading to the explosaion
the Etie Seatch space,
TlUstyatio ns
’A Agosntmt- 9n he wost - coe scenaio, A* my need to
exploste dl possble nodes at each Aeve down to dept# d behise
4in ding the goal. 3f each nede byan ches into b oo de s the totel
nodes exploed could bp y high A also
maintins a ptiosiy queve of no es bos ed on the' f- valves
Cthe sum gih ),the cest to each the node, and EAe), the 2
foust ste estim ate to te goal), whi ch con allect
ofect perfo»man t Ce
Date
Page

bot the tfeoitic

ito ut potoning, the in-Ma algcaim oxploer the enti9e


tyee doun to dagth d 9esuling. in b nodes being eualvated
With alpha- beta ptoningowevet, it can ship Joige p0orh'ons
of he tee that don't need to be exploed, 9n the best
case, alpha- bela ptOnlng can edoce the no f nodes
pvalvated to be abot b Os it effectively hales the soaeh
Space by eliminating boamches Hat o9e not ptomising eastly
in fe Seatch pyo ceS.
Best Fist Sewch go4ithm:
3n a scen at io whese Best Fisst Seotch stelies soley n q heugistle
to choose he nedt nede do explo9e, t can end up erplo ring all
hodes down to depth da in the wo9st case. This means thatin the
ab sence e cffechive he usi stics 9 if the AeU91'stc do es notguide
Hhe seorch ettectivey, # could pstentally eualuae ll nodes in
he tyee syoctuye doading to a time complexity of oC89
Like A* the Aeusd stic Aeads to avexy pooy scecton g
nodes, it could also behave sim jlaly to a byeadh-fist
Seatch in its woarst -ce pesoanance.

You might also like