Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

GATE CSE NOTES

by
Joyoshish Saha

Downloaded from https://gatecsebyjs.github.io/


With best wishes from Joyoshish Saha
Nigori thms

RaHe f_ arow th offunctions

h, , h7)*eri, n o4c< 1 ,
n=
-2d
C
c>2, e c>1, m! , 2
, m', n
NoHe
, n>i
Asymtotio NotatHon
Analo ot
tarws slower tham any ol40)
m ti ple of
3 roVT atar 4han
done

Cgtm) uulthpla ot
ame 7ae ot
) 0G)
1-cER' t c eeR l c e R
m- ) n-o ) n

4)-o (g»)
4 ()

n) ()
gm) 3) (10)
(f
man
)- 0(49*a)|0)- b
n ) - 0(j*)) z ) o(h(»)) )= o (h).4 04 also
-

(maCt z))|
a a
)k
a-i
P+1
0)a och), thom - o (). It i thur (or both) bi-oh
As aüttle-oh. then fh)
, (Smal arc fr 2 , )
HHe

90).Jany any
ove
bu
mot+ bot) the 8 is eplacad by anothuu natathon,
notatioy.
thon tha cowclu'ou uses (the veplacad
that xame( on)
f o(h)

but

xtended Maste's
aT(%)+
T)- e
(»*') a91b>iik>o
Teatnumberu
.9a , T() -e (n)
e.3 a -b , 3 t 7-, Tn) e (n J»* n)
) - (n J» lala) T()
i)f - , T (Cn)8
) (n *)
3. a , ) >o, TC) (n*l2*»)
i) fpo, T(») O(6)
Moster's dor 4ubtroaet conaer T ) = aT (n-b) + o(mk)

O(n a76) a0,b >i, k>o


1. a 1
2. a 1 o ( n ) 5. a 4 o(n*).
the Sorted ubarray so
Soyting iInseytigm Soxt
that the ky i
Anart keysa
pRaced
oe
by
+he.
oento
orect place in the s0ated

Subasray. Herae Sor divioles the array Smto ot


2 until ekm t
rccursive ly *o aet serkd a r y .
570naiing thon mer them
a
071a
ická0»t takay an l w a piveF, places the ivst+ a ABs cec
Comec

poitiw in dttd anay plaur au maltet elm (than pivot) to att o


to the rsht. The euvively call ds 0 the 1eH A
reater

Seorckingr (Lingot, Binory)


O() O
2 Alao vithms
mul+,
Divnde Conauer Min-mon, Strossen's mat
Mga os+, Butck sort, 8inay Seach/
M
Gocedy oithm tractional Ks o(ngn) , 4uffmamv codirs D(ja
Job Aapen.cin withw deadies o(nlsn),
o(nn),
Kirchoff marton toec Hheovetw Cmd#m* spanning -hees fur
Cnne cted
ms s hc mèn
weight edge everytim
(MsT)
inding HST m adj matin. , Kvuskal's alsosithm (nding
inlude all Pewt
HST)- add Tnneetig edges at last, first
.
Set Kauskal's Also),
weisht dpes Am (Disioi.
th 4ST
for each
componomks usin Dissomt Set Ds f
fandin
inding comected
verties are not hn the sama set,4h tn uniom)
edge, he adj
Shorlest Path Stle Soura shorest pot:Keloxatiw
(Shovtes+path astipate),
d
Dijkstoa's ao
ady
S whose mal
6, set svegtces
Csinm paro
uniny qpa-ug
d Durs knou/nu) dlvl) Bellman 40vd
hoptest path son 0U »

gori thw(rela cach ed Iv1 times) o(IEllv1) Lrelanny


kdges 1vl-1 4mes an Ne ar mding shoatest+ pah weihts
th elaxaiow
Length is a maa vl-1 Iv
whew the ah
ath
ás to dejeet+
-ve oyele) "lopalog fcal sov ({fo bAG).
Dy na mic frogamming . M.artaîa chain muttMieatiow # °

be
pas enthes itatioms CR-1 mi, j1
m nmn # Scalor muipicatton needed campute mmatri A .

TC o0n)| st
,jl
mam

mm [iin]
#unaue ubpod blaw possi oie
h+ (n-1) + 4 n(n
2
+1)
cize Ciee 2 s2en
. Lovgest Common ssubsequuna (Boute tora d (n2)
i 0 0r
DP lcs C)
TC o (nm +Ies(!, j-4)
SC o nm manAcs (i-1,1), j70 ; 7 j
les (i,))
3. Shortest potw An muHistage aap
Gaph.
Veris þavitioned
Amto V;'s. 14iik
s+() mu CCj.1) + togt(1#1,2)
edge (u,v) s.t
LEV
in Vi
Verten j,4) eE
to verdex 4

T
i i 3 4 V;
A.
A. Binary Kafkack PsRudo-palynamial -hme)
amd max

C[, valuu s optima profit fr itcwva


e - capauty
W 0
eght.
Ti-1, w1

man f+ e[4- W-;],


c[i-1, ]
#unqu s u b p r o b B e mive | TC 0ne)
tree #objs) x (coapacity) n xe SC o(nc)
Ccursow

. ubset+ Sumv bseuab- pslynowwal me


TC o (n Sum)
also 0 & Sum0
is SS , sum C o (n.sum)
Irue Sum O

LisSs (m-1, sum) 1I is SS (n-1, 8unm se+ In1,


ohuwis*
6.rayalkng Saesman Porolew (Held-Karp Al)
TC 0(2n)
, S-L*)J Sc 0(2") by ttoroy
min
KeS
x subsats
at
si« s-1 s

peito he a.
(K)
Ployd-Nay shall (APSP) be he Nelah+ of a
t
(1 K 0 shoadest ba-h 3om to j
aa
hech oll imoo nediaBe verticas

d (K-1)
in the 4et 1,2, .
TC o Cv') SC matric

o n))
u i ng hem

8. Bellmon fovd 4ao (SSSP)


-

s0uCL to n path
ghortestF
d(,i) be tha lth
atmos
hsse lavgth
- 0 =

S d (o, 4-),
TC e(vE) Dthurwis
m i n d (u, i-1) + ( u , ) J
ev u,v)e E
# BFS Dijksta's Pbemam-fovd loyd-Warshall
aph o(ve) oVE
rHena
Mar tae V,E 10M V,E 300K VE 10M V 400

Unweighted Best+ Bacd Bod fn enogal

e i ted WA Best OK Bao aeneraX

-V whshE|NA

deleet Camt deBect Can detect- Cam detect+


- v ycle Can

gma WA Overkill B
aph hela h d
im coeet

Sorting_alaos logic
. uick sor: Choose påvot elamont4 place
ier o o olems,
elems,
wwtinue until Lach dubpnblem A
o ston 4t cach subprobRew 4
Divtett 2 caua ats, recurively
a. Mavau 40Tt delete
sorted st 3, Heop 40tBuild max hoap,
Smeto ngle 4. Bubbla 407 Compare t
ere Laapoition (rpeat
m-i fims),
a x pace n-Lases, 5. Celecfion 4srt : fimd pos"
adhacentt elom,nepeat
crchange adacen with aR whore 1,2,.. , n - i pases
and
=

mon elem om
a[i..n) swap
aTI to a[J
9msert a Lit1 Amto cormLot otton
mto
6 . S n e r t o n dOrt

aTay,
Whore i 1,2,.., n- paSses
gsDrted part
w°rs+ case,
1. Snserton Aor(e(n')
#tomb ais owaor Aovfma alos vorscae),
Ou5F ordor 2. Meg 40r C O(nlg)
K
OCKn)f H07st
wo7s+ cone).4 uck o7 ( o(n)
3. Heap 4oat (Olnlgn)

averae)
AA
poynomicelly bownd zd E o Clg)

) ponentiolly ff lo fC) 7 oClq-)


71
2n
#BSTs distinc+ kaus =

- Cn
2n
olabeled Bmary pees mmodes m41 - Cn

# Labeled Bmary oees O n nodes mCn

You might also like