0% found this document useful (0 votes)
4 views

Notes Dsa

Notes of dsa
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)
4 views

Notes Dsa

Notes of dsa
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/ 14

Tuecday

Dato hruch1res Date 02 /O7124

Introduchon
Clossical Conpute only binory togu6ge
(,0)

Transltor /Compiler ) Toterpreter -


A A Compiler is 0_sofigve tool thot translote

bigh-level longuage into mochine longuoge (binory.


Operators. GOperonds.
OperaBors referto symbbls that perform operat
ions OY more operands.
Operators used to monipulate variables ond vavg
)Arith metic peratov (+,-,*, )
QJ Corg paison operotor (==, != , <,2)
3 logicd operator
JAssignmet Operotors (,+= ,-)

Types of Doto structure.


) Doto
2) Dato
Ognnizing)
Processing
Asyntothc Analysis. < medsuring
Measuing running ime of Agorithg
- Thr ee Woys 3)

big
bg 0' Omego Theta

far ( int i o ; i<0; i++)-n+4 hme

cout<<: n ime
furs
Cose2vesge
TNoste Cose

take, 2 n ) = C=3

Ucoer bond

:nis irpt.size
wednesday.

Dats 03 O7

JAveroge Cose:
VC posithve constont

f¢o) = 20+1

fom)

loser bond.

8] 8est Cose
fio) = e(gco) fens Ci gcnfen) Ca gen)

DPPer bond Tighter


bo nd.

loser
bend

Sort
L = 4.6,2, ,5.9.3.
2, , G, ,5, 9,3
!, 4,6, 2,5, 9,3
Paçe No.
Date

for n(o+)
to

exchonge ( Ltij,Lj)

iz!,j: i+I=2 i=2,j: iti*g

2)1 2)5 4>5


e1>5, (co)R 2)9
2)3
I2 3 G59 4
I46 259 3 2 4 2593

E5
2 2 Gg/4 t 23 56 9
Ji+I5 5)9
Thursdoy
30M5Pa tio 3

Aito n-!
2 to n-1

i= n-2

(0, ,2,3, . o-»)

£= n(n+1) +

n (n+)+n

n2+ 2n

avot^) =,(n2+20)steps

Step lunit ime


: (n2+20) unit time for one code/program

fio) =O9cny
fin) O' (n). Speedup foctor.

(Gronth of fyne
Naste Cose
is quodratic.)

-Average Case =2(n)


Page No
Date

\Sorting element
L=,2,3, 4,5}
for i=0

for (j: i+! to o-) t me

if ( L CiJ >1 CjJ)

exchonge ( Lc,ZEjJ)

if (check fist)
(exist)

The highest degree tèrrg addoys domiates


the speed -up of algoithm governing
OR!

oThe speed -up foctor' of dgoithy is


gvered by the bighest order term in
eguaion.

feny n2+

The grosth of dgarithg depend on he


speed-up foctor af the algorithm.
I4to

outer inne loep.

Speed of dgothn
DOMS Page No.
Date

O(ny
. Groth of progrom is

L,2,3, +,5, 6, 7,8, 9J


L!2,3, 4] t6,7, 8, 9]

T(o) = T(2) + T(0/2) + C

T(O) 27(u) Ca
Put in eg

T(O)= 2x2T(4) Co]+C


=.4T (l4) +2C
4.=22 T( la2).+ 2c

T(o) 2 J (lok) + kc

k Jog?
T(n) = nT ( ) t C Sog n

T(n) ' DT(0+ C.log

ntclog.
Speed-up of algoithr is
Cn

Speed -up of aJgaithm is nJogn


Page No
Date

.: The
chonge in algorith leods to
dro
change in
speed-up of adgori thm,
.Speed-up foctor K
rurime of algoithrn,
eie Speed -up foctor

-ime takento run algorithrn


oa/o724
Mond
1'=,2,3,,5, 6,..}
seorchin element k

if ( k < 'L 2])

Teo)+ = T(Ol2) +C

k zDog 0

T¢o) T(9/0)t c g(n)

T(oy

Ten)
Recurence
To
algathns
Put
Compure
(^2) T (gcn))
fcn) girenRelationsTP
T(4) Neglec
2) 1)
fen),9
e(g2?) in T(n)E,2T(le)tn. Neglect! therotico conputed
T(O2) (n),
T(^l2)+ :2 n2+ 20
(4) T
term"
lower
Constaotgrder, constant
+ne
eq() ,
Ca
running
(4) T Coeffcient.
DOMS
07/2024 DatJO
e
eg
’O(n) Poty wedoesdoy
repres PapeNo.
2h qur ot
(). T 5
ented

n.
DOMS
Page No.
Date

T(o) = 227(°/4) 4

47 ( / ) 2n

T(n) 2? T(o2)+ 20

T(o) = 2 T( /ok) + Ko

T(n) =.nT (n) +

n T(I) + n

T¢n) =
log,n
This is Aet recursion

logn)
algorithm,
Master T1ethod
Tio) TENz) + n2

Condiion:
form of
T(o) = oT(nb) + fin),
ahere,

T(o) 8T (O/z) +
mhere b:7:
DOMS Page No. G
Date

Tre
Three Coses:te

) CoSe I:
0(n'
then
(:E iS +ve)
2) Coseo2
fco) ecoS
then
Dogn)
8) Cose 8:

then (.e is +ve.)


e(fto)
Tin) = 8 T(9)+o2

log 3 0.5645]:e
Jog
0.5645 0

Cose 3
e(n,° feg n)
Tuesday
Ds 16

Algorithms.
Set of fnite 5teps/ stoternents
specihc seper Sequence to get ofgoriszed,
desines
in
poly nomigal time
Input / Otput fnite

tirne- bounded.
( Polynomieiol )

agorithrm Sum Ci)

for ( i o to n-)
o

Sum SUm +i j

return Sum;

Total step’ tn+4+ 4+n : 20+3


J.
Nome. of algorithms J
tosks DÍ. of
steps / required
fco) = 20 +9

-Asynytotic anaysis ( O,4, e)

Constant
C,
DOMS
Date Pase tio. 7

Fon)
cgen).
Cigcn

Soving elemeots of
ist
Algorithrn Soring ( Lto3) Oscendin2 Order.
for ( i- o
to n-)

for ( j= i+1 to n-)

if ( Li) > L Cj3)

return

n2
2 2.

n2

-fcn) = Ogc)
fer)
Tuesday.
Date 2307 2014
4

Doyttioning
fred
Unsoted Unsorted
G52 15 8 9

Sml gretterthon

Povtoning elemerts.

+Atothm Portition (A, P,)


list Stort ending
adgorithm qwchsbost (A,p,,noe index

if (P<r)

( - Povtitnng
9= partiion (A,P,r) inder of
pottenng
quchsa ort (A,P, q-)
qwcksort ( A ,944,r)

Wgorithm portihon ( A,P,r)

ohile fALJT)

for (i= o to x-)

if ( ALiJ > ACj))


exchonge ( ACi], ACjj)

You might also like