You are on page 1of 14

List and explain the

ditexent asyoantotic
notations in datarsthictux» son
Asynoptotic Notation axe lanauage thát allouos
to behaviour as the input
size or tne
algoxithm iacreases, This ic alsor knotwh as an
algoithm qxDth ate.
Big Omea t is wntten as
Snall
bmega Itis iitten as i
i Theta
:

ASyoptotic conapai[on Numeic Gorapan


Operatoy Sonoperatar
lour aaontho is alGimething) A numbex is <i
Anumbey isiQ
A number isK.
urr alaothmis A number is
|ouY Lalgonthn isw Anumbex is>.

FOR EDUCATIONAL USE


Sundaram
CoList and explain
that Can diteyent types ot apeatio
Tpe S o
bepexomedonidata
opexa tions
StnuctxeA!
Seaxehing. aveaiven helowi
Dsaxtihq
üoseinn
ivDe le tion
v)wpda tian
Seaxching r ale can easily seaxch tor any
data elements in a data ctuctuYe
)soxting
E: - taleCan Sort the e le
aentseither
in ascending ox descending Axdex
nsextion- ale can inseyt new data ele
ment ethey in ascendinq or
de Scending axdex
i)lnee tion e Can delete thedota ele ment
yDm the data Sthicure.
v) updation ae Ca update or. eplace the
eisting elements amdata
Stuctuses.
Q3 DiEexentiate betwe enData stnucture and
kile rganization
H Data Stncture
xangement o àtaStnctueis
data
an
Tt inicoaputexiS
makess tthe data quickly availa ble to
m
he
pDcessox ox oY Yequired opexåtions.
Datastnictuxe is aisottwaxe axtitact
which allowsdata to be stKed
ad accessed fok eiq: oaanized
Iahilecing
shepping we bsité iké lipkat or Arnazon
a
the usess
Cantyack
nowwtheirlastxder
them:
and

Eile
Oxganization Fle is alcollection
xeCoxds eleated to e ách cotheriThetile
size o memy andstoxagemediurs.
ensuxes that ecoxds axe available
tox pYocessing Tt is usedto detemine ar
e7icient ile xqanization or each baic
eleation fox eq If we ant to etive
Employee ecords in alphabeical rder
o7 nane Soring the ile tyemployee
by
name me is a good *le oxqanization

am FOR EDUCATIONAL USE


4 Deine Aaywith its Syntax How to imple
ment 1-D arxay in ct+t?

A) An aray is used to stoxe acallection of


data, but it istten moreUse to think
anarYay as ia collectionovanables o
Same ype
Instead odeclaingindividual vaiable
Suchinusbero1number 99yo
dec laY aine axra vaiablecuch a humbeY
nd uyenumbes o]Liniínaber Ca9]
fo Yepxe sSentindividual' vaiable
fü)The lowest address ceresponds to the irst
e lerment and the highest address Comespond
to the last ele ment
ivo are ta king a survey a on- people
haveto sto Yé their age

Syntå x to declaYe 1sd arxay

Cpp
datatype
name Catay-size]
Cpe
int DumbeY l6l; / TDeclareint
axray o Size S.

FOR EDUCATIONAL USE


Sundaram)
-dimen
high
values o dele
index
numbcr
elementSo
very &
tioo their 0insexión
ments:ohose maintaining
andidisadvantages
advantages
saxse
a
large
dato
soeciaitupeo
which with niatices
nwl
arayiond spase
a EDUCATIO
FOR
USE
elenents
o aReduced
memSage
ele o
o isocCupied
arraconsisting onsox CoMplexihy
headtox
out
hay
is stoxage
operatiòns
spaSe arYay xDm only^n2eo
natix
Vantaqes
Disad
iadvantages
s ovex
aperation.
Additional
pxopoYhon
Sparse elements
Explaìn Ficient
SpaYSe bFaster bExtYa
Sial
itS
)
OS
by SpacegiveeqaY
equitd
byalgaithm
isthe
Space okey
in
measued athe
algotam? aeasied (o)
Connpaison
n and £ SpaCe
dieent
typeso
Conmplexities:
tu0 thenumbeY
alaoithnand n
algnthim
tine is
tae is o
an ot timei Storag
as SoxHnq
algoithm:
Spale tem
ot aricieny
datathe
Such
ity The
bythealgoithmx
anY in
cóunhnqThe
Comple n operation of time
alaonthm
data.
input
o
e i-
whiehdecide
iaput
Complexity
is TimeactoYr
actox
is X by xunnih
=Suppose
Q6lhat
sizeo bythe
blspaCe
Thethe
q . alhat is an alqoithm? Eploin the diterent
types o Compleit
An alaoithm spe'cities a sexies os steps
hatper kom a paxtcular connputatioro

i) Algoithm oesemble xecipies Recipe te ll you


how to acComplish a tak by pexoxing
no o steps. foyea; to bakeacake steps
Care ore heat ttheoveDmix the lour
sugar and eq4s thouahly intD baking
pan
An algoithmis an unamhiguous desciph
on that maees cleaY imolemented. In a
|Xecipe step Suca as " Bakeuitil done" is a
unambiiuous
Atexwokdsy l stcps ae done &designing is
done hen i s ambigiuous Also, alaoith
a quarantee to pxDduce the corYect eult
Tt'S
Yar ly Usetu analgonthmetu
laxgest no. 99 : of time, but I tim is
Lalgoithg ailuxe.
chaxac teistic s o* Algonthm i
)nambiguous Algoritam should be clear
and unambiqiDus fachiot its ste
& iplop shold be clear &only one
laram) FOR EDUCATIONAL USE
meaning
Thput
well de ined inputs
loutput i Analapithm should have
wwelbde kined outputs

ivfeasibility It should beeasible Aith


theavailaleesaurces.

)Thdependent An alacithn should be


Step-by step dirhwhich ehoild be
Lindependent at any pDgramming
Code
'Rlhat is linleed'list ? wite &lexplainan
alqonthmto insert ianrelementtthe Start
o singly inked list.

= ) A linked ist is a data stnctuethat Ca


Stoe n inde ioite a i t od itemhese
Connec ted usinq pointer in a
Sequenhal manne
iTheYe ae two type t linked ist sin ly &
Ldoubly linked list
Tn a singly linked listeveyy eleoent Car
Some data linked to next element
the hand eveyy node in doubly linked
kstcontain some ata,a link to nods
& linleto hepe Vious hode
i h e ele ment O linked ist are Called
the nodes. A node has t o ield iei data
next the data fie ld Centain data bein
Stored.
Eachhode isdiVidedin tw0 paxt
)eirst part Contained infoxmation
vseCond paxt Contained neet node

Thtoxmation Net
aate an/a
element o algoithmlpiogrdmito'
axray in sat the'
ascedingOxdex
ttincdude <iosttemh
#inelude cconio h
Void main C)
int Cio] temp
Cout sc"Entex any to niin axry n
kox.Ci=o,ic lo; it +)
Cin > ail;

Cout KlnData be oxe Sorng


Cout<< a Cl
?

i Cari> aCit])
ternp aCj
aCt=temps
Sundaram FOR EDUCATIONAL USE
Cout c<"ln Data atter Sóing

Cout < < a l i i


)The oxdeY 0 aowth o an alaoithm
deined by using the big ohotation
The big o notation has been accep ted a a
tundamental technigue or descibing the
eiiency o an algonthm
following table (ist somepossibleroxder
o gDwth theiy Cospondinq big o
notation

Oxdex Big
gxDuth Alotation

Constant
Logaithm oloan)
on)
Lineax
loglinear
@Madxatic
Cubic
fopohentia
MatiX addith
pextom
nte a pxo4am tD
qQ LLandSubtraction

-includeiosteamh
include <onioh>

itint
Cin mn
int i
int mat 1 (m) Cn),nat l m)(n)

oxGoi<nitt)
Cin > mat 1Ci1C

cin2) mat CIC

tox Cit0 i< mitt)

mat 3CiGl: mat 1Ci]+mat CiC


etuxn o
?

o1alite an al othn to peY fasmm Sinnmation

Tnitializeot vaiable axray


Value
i tox each element in aay
Step y odd ele nment to sum
Steps

You might also like