0% found this document useful (0 votes)
40 views12 pages

AOA Module 1 Notes

Uploaded by

williamssayyed
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)
40 views12 pages

AOA Module 1 Notes

Uploaded by

williamssayyed
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

hat j5 an Algortbm2

Ao alqorithm is a inite set ot (nstucthionsthat,


iF
followed a ccomplishes a task aoon
partialar
In addition allalgorithms must gahsk tne folloain
8Cate n'a!
Input : Zero qugnhtes re externaly
Supplied.
2. Output:At least ne quanithy I5 produced
3.Detiniteness:Eachinshruchonisclearond uhambiauaus.
. Finiteness: we trace ot theinstructiobs
o} an

ahaorthm,then ioral)Casesthe alg


terminates after a finite
number o steps.
veness.Everyinstruchíonmust be very ba sic
5. Effecti
90 that itcan be carriedout

frograrm
A
A proaram is the expres5ionof an algor'tbmin a.
proqramming onguaqe lahquaqes axe desiqsed
Such
Gretnat ensh 9entence hsu a oigue
legitimaie
meonin
Someimes words Such cu proceduTe Funchon,and
Subroutine are used
Used Synony mouly tor prgra
he Stud o alaonthms includes many importantand
gctive red 5 t e sedrch There are tour distnctareas
.

Stud- One identity'


1.Houw to device alqorithms
2. How to validale alqorithms.
B. Houw to nalyze alqorithms
How to fest a proaram.

Shot onOnePlus
2025.08.0611:28
How to devise algonthms art which may Dever
algonith i6 an
Creating
be Flly qutomatedimportant desan technigues uck
There qre some
liocar non-linearandnrqer pragramining
are not covered bere
here a5
as they are traditionalky
Coe
How to validate Alqorithms
Once an alo. i6
denced iti5 necessary show
that it computes the Corect ansuer tor al)posk
legalinputs. we geier to this process as alaune
validation.
3
How to Analyze alqor'thms
Tbis eld of study iskho wn a
$ As an odaorithm i6 executedit
uses the
Computer's CPU to perorm operahonsandts
memo to bol the proqrm and data
emog
AoA
performance anaysi me Fers to thetat
o deterrmininqhow much omputing timeand
6torage an alontom Tequre s.
How tO test
gram
d sing debuggin meosren
proiing perioroante
-ent
debuagioq y process o
executinq proqrams 0?
-Sample ato ses to
Teswt
determine tauhy heher
cCur end S0, to Correct hem

bovn

Per

oound
tomplenity
Shot on OnePlus Lower

2025.08.061hptdata
eoo
Os-Ho algohm is

ecoleei
n ncal oesf d scehoso

rcer
Manpuoby
t
What is more impostant thon perormance

madalarity User- Fr'endlyness


Correctnes5 Proqrammer time
mauntainability Simplicihy
Functionality extensibi)lity
Robustness Reliability

why alorithms
stud pexforrmance2
Algonttmshelp w to understand $ca)ability
Pertormonce oftendraas tbe ine betwees ha is

teosibleand wbat is (mpass ble. i


Alqon thic athamatics provides aJanguaqe
mathermatics o

talking aboutproqrambehavior.
Pertormance i5 the Currenc
uTrencyotcomputing
Hotahion
tsympto tic

Worst Bestotota
Average
Co se Case Case

Biq 0h.
Theta
Notation Notationaoto20
Notation

perbound Lower bound Avera


Runct'on Funcion

Shoton OnePlus
adechesry

2025.08.06 11:28
Worst Caue

It i5 the lonqest time thot an alqo nthm will User over


all instances of size n for q
Ven problem to prodce
desired result.

Averase Casei
Cas

It is the qveraqe time (oraverage Space )thatthe


alqorithm oi) se Over dll instdnces 5i7DTora
venpobem to ptodue desiredest

Best Case:
the shostest time (or eat space)thatthe
algonthm wil) use startioginstances o 5iza n tr
gi ven problem to prod ucea
desfred reswt

4nptohc Hotatona
Calaulate the munning trme camplehy of an alaonh

BiaOb Ho tati'on Norst Case


The Notation OCo) 5 the tormo
the upper bound ot an alaonthnms
measures he Worst Case ime omptex 0r the
amount of time an
longest
take to complete
a3it
T
fco) indicat
)ven iof

ooC9tj upper
bound ttme comar
he.
fCn)
coropex
blgonthm

q Cn) i5 on
Toe
aymptothic upper
beund For cn )
Ioput do
Shoton OnePius
12025.08.06 11:28
Omeqa Notaljon Best case
The notationn
Co) isthe For mo) y to express the
Aower oound at an algonthm's runningtime
neasures the best case time complexity
0Y fhe.
best amound ot o time an alaoritbm can pos5ibly
take
to complebe

fcm)-9Cn)4C-fcn)

baund
eerLauler
cooplexity
Time

K
Input data

C) indicaleven jnpw
gcn indícaes bJe best cae time Complex/ty oftheazo.

Theta Notation
The nohat'on e co)is a torma fo expres both
way to

the ower bound upperr bund of an algontin's

unning time with A verage coe time complexiy

e(Fn)=0(F)& g cn)=(fe))
Bound
lower BoundK Time Uppex

Shot onOnePlusRunning
2025.08.0611:28
WoST care

4m iveninput

go)Bestcare

Follawoing
aist
i5 ot ome
s Common symptot'e
Htaho

Constant
ic
logarth
oear
n log Cnl0qh,
Quad ratie
Cubic
palynomial
Exponenhial

Shot on OnePlus
2025.08,0611:28
Time Conmplexity
deal,u)ththe quontiicat
time taken
lon The amount o
by a set of
oF code or alaonthm tomocess.
psoces
Tund5 a funchionf
the amount ofinput.
Tine complexih is de'ned oOU the number ot tines
a onrtblar bstmuction setis exeutedather than
the toa time taken. depends on 3ome externa
Factorskethe compilex ed the poCessoT's speed
tc:
Thetime TCe) taken by aproqram Pi3
the Compile time ond tbe runtimeCexecutton

Constaot time oY 0C1),s


the time complexIhy
tot an alsethm tha aays Le the-6ame nd.
of aperahons,reqardleso0 no.oelements
bena_
operated
For alaontb to returnthe lenqth o
single operahion to return
the
index number
er oftheindex bumber o the ioa
element inthe ist
doesnot imply that only One perahion is
Gused that the
butrather number oF peraH'ons

ways Constant

neaT Hme oY 0Co) indicat thatthe time


es it
takes an ag0 rih m qTOus in a linear
fauhi

as ncreaes In time searchin


linear
list oo0 recods shou)d toke rodahy l time
\ong searching
which in turn shoudd be take
a st lo0records,
goughly l
searchng Jist oF o records.
longas a

Shot on OnePlus
t2025.08,0611:28
Quardrattc
Hasnyanitbmis
Time oY 0Cagnindicotes
tbo the
needed to n an olgori
thm ro0s as a togoh ro

n For ex ample- in a ion


6elect 5 onst
aqonhn
hstis sortedb4
b repedledly ndingthe
min Vvalue the unsrted patf of +he )
and pla cinq the beqininq
this vaue ir the
Because the no o operations needed to fnd
minm va ue in the 'st ago u5 the lengtb O

the starousand the no úes


ValMes
Hhat nust be sonted ago arOUOS with n,the
total noo o operati'ons qTOWS uwth n'.hoe
algonthns qrows much faster than tbose ado
ipeor time

Loqa mtbm c Hme Coq n) ndcoe d the


time needed to un alqp ithm
-nhm n.

tit
o

9e0rch orted ispertor


med The istis Gearched b divding inholE
repeadey untlthe desired elemeot is ound
The ro.o ivsians cessa to nd the ee
necesso
arows with the
thon a)4
proporton to n
noq n)iss)ewer
routh ratetho OCnth theecyotonw

have ower i me
mplexitthon neor tfmu
algonthms.

Shot on OnePlus
1 2025.08.0611:29
,P, 1p-7ord,f-coglete

PalynomoJ &
on - polynomia time
Poly nomials only involveaperatton of
sub fraction mutiplicahion addition
dnd non-negahve
inteqeT xponents.
on- Polynomuals CoD hvolve otherOperaond
exponents
polunomia-timealgo 15 one whose running
time qrows as a poly nomial funchtan at the
4i2 e o isinput
ardeT
NP-Hgrd

ard
medium

Easy

ent EasyP
Medum > NP
NP-Complete
Hordest Np- Hard

The pin the Pchass 6tands or Polyo.dmdtm


i5 the collechon decision problem Cproble
answer) that
de 6HC
ermini achinein
Qqn be 6olved a
m

poynomial timei
Shot on OnePius
|2025.08.06
11:29
eotures :
P-psoblems jis eauy to
Hod
The solutionto
often a class camputarionalneo b le
Pis
Golvable ond tractable
th are
poblem5 Can be sole
Tractable meanS that the
in theoy as well as in prach'ce.But the
that can be solved in theo but
proems
in Qractice ar known
not

This class Confansproblemsmany


the qreatest Lommon divses
Calcalatig atchio
mamum
Fnbin
Merge sot

The in N las6 6 stands fo Hon- determin


Pol nom ià Time. It15 the collectronot
dec'sion problems that Oan be Solved
be a non -
-determintsHc nochine in ponomia n
time.

Feat ures
The 6olutions thefla55 are hTd to nd

since tbey are non- determipst'


beig Bo1ved a

machine but the Solut'ons

Shot on OnePlus
32025.08.06 11:29
vere - O Cn)- Bedr
OCn - Wors

Selehiem
Ne -hard class
An Np-ba rd problem i5 at least as bard os
the in NP and
hordest problem qdleS5. s

that erenyoblem
prrobiermsuch
redaces to p-aro.
Features
1e-ard09plemsaTe notin p

themHmeto chbeck
takes a long
long

Shot on OnePlus
412025.08.0611:29
Speibic
oblem ,aste method

Method:onlybr
3.MOster
thon

MteY
ubtitutionnethod)
Method
i a direct 00y tO

follouoing
qet the

type
Solution or the e

Method
wOTKSOnly that an
ReuYence

xonxhormed itotheI1owinqpe
a T(b)
FCn) +
Tn) =
ohere

€.9. ReencevRelaio

1. T(n)=T
()+n
+n
. TCn)- 8T(n/a)
3. T(n)= T(n/)t c

nd
d Can be Solve
Anong thil only
theorern
uaing mater

:
loluton
Tn)=
U (n) depends on hCn)

hln) F (n)

Shot on OnePlus
t 2025.08.0611:34

You might also like