0% found this document useful (0 votes)
62 views38 pages

Organ: Relatronhip

gugygftdu

Uploaded by

Riya Singh
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)
62 views38 pages

Organ: Relatronhip

gugygftdu

Uploaded by

Riya Singh
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/ 38

D a t a Avcture Data hructure i> away of organ

all data items md relatronhip to


intormat ton
Sata > Anything to qive each o+her.
is Calle deta.
Tpes of dato Aructure
&stuentName, AuclentRollno,
There are mainly tuo typu of data
Structure > Repreentaditon of data is Aructure.
Calledructure. Data Aructure|
aph, Arrays, Lis4.
Pvimitue data Non-primitie
Data tructure ShwctUre data rucdure
Data hucture Data + ructure
Ineger lea] Characker Lear Non-i
Data hructure is a way to tore data Ucke] data Shnctn
Ome ovgam'ze deata so that i+ Can Aays Tres
tacs
be ed &ffitiently beter Woy
LiikLis*
4

L3

3
A-
An Asray Conbe fied os an infinte
Collech'on of homogentoa (Similar +ype)
&lemmg.
Amy are aluays Stored in Conseuhive
Cspecifie) memory Lotatiom.
ArrayCan be Store multiple valus
wweh Con be referenced by a Sngle nane,

ges of Arayg

SAingle muwuona l mult&Amanuona )


Aroy Arys
Aingle &mawional Array7+ albo
Rnown as

na Dmaunuonal 1b) ATay


Its e one SubsCnipt
y to define
+he slemawts of AYrays
Decloratn Decloraton tuJo &imensional Arrun
data-+ype var.name L8xpreAon] Bota-Hyt Vor.mame Iro] [ColomAJ
ex i'nt mum I1o1, ex
in mum L3] L1,
Chor CL51;
Inittal Zation 2-D ATay
Initialiging one-menwional Array
baka.type vav.name Lpreion] / Voluea. =
dado4ype var.name Lrow] [toloma] wlu
int mum Li] {,2,3,,5,4,,8,,1o
i't numLl]= {,2,3, ,5, 6
Char a [s] { *','8',c, b, E}. Or

multi- bimenunal Arrays multikme t num LaTL] =i,a,3,4,5,2


Ars move
2
hin on Subscript to descrnbe the

Thwo
Arras &lememds.
Mmemuonal Avrays
tIL?£
I+3 ume tuo
b3
Subscrpt, me SubStip
represRmt rou value nd SeComd nomo3
+O
+o
nu 4
SubSciet to re presen Column Value.

14 maiwy tov motri'x Re presnati


wite a progrum to read& write ome
Stacks (Data hructure)
Dendnal Aray
+'nclucde <Stdio.h>
Ao tomduredineuhoul Stack a Non- Primtie uinaor doda
include< Conio.h> Structure.
Voi matn C)
Console in put su
ChBCr), 9udo + a n ordered L'st in whith
i n t a Li), i addihon of nw desta item omd oelehbm
ClrsCrC) of already &xisting data item i'3
prink f (Enter the Aray Elemunts"),
End& kmoun
done from Onky me
for (i o; i<=9; it)
0s ToP of stack (Tos)
SCanf (t7d", a-a[i),
POP PUSH
the entere d Amy ' ,
TOS
Print f C"
for (-o; ik9, i++)
Pri (" &\n", a
til) oded ele memt uill be +he
Tha Loa
StaCk
sth), fira tobe Removecd
from the

tack i3 Called
reason
3 Th is the
Loat-in -firai out (LTFo) +ye of Li'Bt.
Oeratims on Stack.
Stock operaHion a Algorithm
There oare two ofera4lom of stack
proteas of adolu'ng Stack has two Operadr'on,
1PUSH operation>The
te the top of stack i
ew
a glement PUSH p&Tatiom
Called PuSH operatiom.

is addung to tack DPop operaton >


&lement
Euery uw
. The procesB of
D PUSH Operadin
top i incrementel by gmg. tlemed
I n Cose the amy foll amd no naw skna Adling a nw

Callee PuSH
of the top of stack i
Can be aled i+> Called Stack fulA or
Stack ouerflow Conda'tibn operation
PuSH operatim Top isireatel
every
2PoP operation >. Th pro Ceq8 of by one.
Beleking an element from the ToP ToP +1
+op of stock i Called PoOP Oprar'ey fu new
I n Coe +he Arrmy i no
After yary operatton he
fop adled. +hs Csnd' tion s
elemat i
Stack ip decremenked by ome. Stack ull oy Stack oerflou
Called
If here is no eleme on the
stack and Conation.
he pop is rfomeß han
thi's wil}
rult i'to Stack Underflow Condilion
Algorithm inrh
for Hem ido2
an 2PoP Operatim
+h tack (PUSH opradion)
The procaAs of deleting an elemunt
from th top of Stack i Called Poe
pUSH (Stack mox S) item) operat'on.
Af+er Every pop Operation the
Step initialze
Sek top -1 Stack TOp detrememted by ome
SHep2 Aepead Steps 3toS Until Top<msije- Top TOP
Step3: Read I+em elememt On the
If thure t's no

pop operat ron


Step4: Set +op >top+1 Stack amd +he
performd thun thu's wil
item i
Steps: Set tack ro] STACk VNDERFLOW
xeaul+ into
Pvink Stock overflow" opeahun
Step 6: Comda+1m.
3 ToP2
3 h poP
20 ToP ToP-
Top-
t Aigorithm for deehing an tem from +he Stocke(Prefix& pokix) SteaCk
Stack Notatn There are +hree
Statk (POP)
Notat'sm
Pop Statk maxSige), Hem) Infix Notatiom whre +he operator is

Repeat Stepp 2 +o4 until Top2o wrHen in- bekuween the opern.
Step +operator
A+B
Set item Stack LToP] A, operome
Step Operator ts
3Prefi Notation In thi
Step3. Set +op+op- the operomds.
wsiten before
knoun as polr'sh Nokad(on
is, I+em I+ apo
Step4 Print, No, deluted +AB
Undler flows. s
Print toack In tu» operalor
Steps: Postrx Notation
w t e n After
the Opermds.

known as Suffix Notadon


1E i2 also
Ex AB+

Convert the following Infix +o Prefi


Omd pofy fr (A+8)+C/D+£^Fl

Prefiy(+8)»Clb+ eFl
+ABCD +e^FlG
Le+ +A
R*C/b+£"F/G (16 podfiy (A+8)* Clb+8^Flq (
RCID+ AEF/
Let EF Ra Let AB+ R
R CID +Rl
R/CD + Ralq
Rx C/D+6FG
Let C D R3
Le+ &F Ra
R+ AalG RX CDt RalG
ARatRG
Let AR Ry R(CD+ Rl
RAa+ Ry LetCD :R3
*R Ra+ Ry
LetRRa=Rs RRa+
As+Ry LetRl=Ry
+Rs Ry
Now &nter he value of Rs, Ru,Rs Ra, R,
+*RR31 RaC
R Rs+R
Let RR Rs
+* +AB/CD/nEF G
R +Ry
Rs Ry t
|DDD DdD|
aweves
veue a Nen-primiive Linear lata
Aructure.
Collection oF slereds
I+ isam hemogento
adced at
in w'ch new elemamk ae

one En Called +he Rear End, amd the


deled from othr
Exisng 8lemet are

end Coalled h e front En.

The firt addeel elemank will be +hu tim4


from the queue. that 's the
to be emove

reason ueve i's Called (fI Fo) fiyt-in


f i t ouk type Li34.
In qweue Every insert operation Reor
is inCre mmtecl by o n
R R+
Cwnd esery Releted operatin front
iincremented by on
FalR-1 F: F+

Empty ueue
operadiom on Cueue (23
T o insert an &lemont in a ueue

26R-| F:o Algo GINSERTaUEUE[mil,IT&M


l o20|
Step Initiali3ation
Set front - I
R2F o se Rear= 1
iner 30
1o Ro 3o
Step 2 Repeat Steps 3+oS Until
Rear< moxsize
dlkel &lemad. fia delete lo Step 3 Real item
Step4 f fromt = -| then
20 30
front O
Rear O
delaked SseCond elemend.
R 24 Fz2 eleRear Rear+ |
30
2

Step S Set 8UEUELRear]= item

Step6 PTid, Bueue is oerflow


Deleke an Elemmt from the 9ueue > CIRCULAR UEU
To
in whith +he i'nserho
QDeLETE (dueve[moxe, tem) A Cixcula 9ueue is one

slemut i's done at the vey iiTa4


Until front > = 0 of a mew
Step L Repeat &tep 2to4 LoCation
LoCattom of the qwee if +he laat
Set item : veueLfrond7
Step of qweue is full.
If front == Rear
Stee3 fA
S frot-
SRear =-|
A A queue overtome the problem ot
Cirtolar

ront fronk +| unutillged space in Lintar queves implemauel


0 ara ys.
Step4 pint, No deleted is, item CarCular queue has following londt1on

Steps Priwt"@ueue i EmptybY Dfront will aluwa be puihing +o he fivpt


sleman.
Underflow"
If ront Rear the 9peue will be émpty.
2)
3Eoch hime Blement i3 t'hsertel into
a nw

+he queue the Reoar t ntremente by ne


Reor Rear +1
elembnt i delule from tha
4Each time an

uue he Value of tront is intremantel by ono.


front front+}
Insertan &leman in Chrculor 9uewe 6 6eue (Dota &taucture)
aTNSERT (CRUEUE LMAxSI
ZE], Iten 0peratton n 6ueue
Algo
Step iF (frod= =(Rear+). masie) 19, 30, 39,4o
wyite queue is overflow Exit, ) front marSe-3
Pear- eme eye
ysee
ele toake the Velue
a 3tos Stap Repeat
if Cfront -) Amase-
Aront O -I <3-1
Rear O
-1<ge
&lae
ReoY=Rear+)/, maxSiz) 3Read item
Reod lo
ASsgn Valae ueL Rea] Value. f:-
en&F
S+epa vit
9 C o item
Se
R At DELETE an &lemant in CirCular 9eue
R Itl 2
set 9,R]30 Algo QDELETE(Guee [mosu] 1+em)
RearMaxja-|
O <3-1
O rue
10 20 30 D f (front -1)
Wrte Oueue Underflou Cne Evi
Rea 20 Rearmarje-1
F f:z -| item ueue frond7
a<3-
O- faL4e f (front = Reov)
R Rt 9 eue s overflew Set front -
A 0t1 Set Reav - I

Elae front ((front+), mavse)


endi S4ademe
tem teel
2. evit
Rear mauje -|

+ue
Read 30
O 1 falag
Elae
UEUE (Dota Structure) (
Selete oeratron ueue

l o Ro30 ma se 3
R2
F-0

Set tam ,Lo]


tem I0

O=2folae
elae

f Otl
tam Ite

203o
fl Rz2
| 20 30 4) tem Reletel Linke 1Li3t8
f 1 R:3 ructure, in
A Li'wked Lipt isa Lintor duta
not Mored at
Coe 2. f>:0 f- Wh'ch the Elemewka
are

e
> 0trse A- Lo Catlom.
Contigusu mamory
Hem 9 7 F> O Structure
dymane clota
tem 2
-|>20 ¢alae A Linkel Lis+
1s a

a Li> t 3 mot fixed


Th No. of
noes i'n
f f= =A tap 5: 90e0e iB Eme one h r i k
on demmd
Cmd Can grow
falae ueue , Called a n0ke, Whch
elae Underflow Each 8lemavd i
f Ft
f 141:2 hou two part8. intormation
the
tore3
item ' eleked info part
which
mex4
20 dulekel whuch porntto the
Poi'nter
Omd
3 03 0 &leman
F: R2
1o
info Poie info pider

Noo-e
a tem 4 1
tem 3o Sforc? Ento Enfo -no
3 f f: : A
s f-
Alvamtags of Linked Li'ats Operaton ON Linked Li34: (34)
The Bauc operatim to be performal om
Linke u3p are dynamc data stweiure: Thad
+he inkel Ligt are
,they Can qrow onc think
+he exetut1on of program. D Coeati'm Th'» operatiom are ud
dun'ng a

Efficiert memeory U4ilzation: Here, memor


+o Cre ate a Linke Lii. Zn thijs
mode 3 Created Om Liwked to +he
not pre alleCated. memoy b allbatel
-

Anoher mole.
whenever i+ reuired. And i+s dealloCute
2 InSert1on th3 operat1on 1 usec
Remoued) when its netomger neecde
+oiney+ a nw nocle i'n +he Linked
3Inserton Cmd
delettens are Eaier
Om ef Frcient I+ PToule LiB+. Aew nee may be tnserteck
i'n
flexibiliy A +hebegimung of a lindeed Li'%
inerting a data item at a Specifred
potion ownd delekton of A+ he end of a Liwked Li3.
a duta 1tem
from the Specifie posion in a Hinked LiM
given posilion. A the

mowmy Complex APpCattons Can be Deletion+ Thp operoattan sed +o


rom
eoly Comied ouk with liked ipts. dete a n item (a node)
h
+h iked Lia. noe may be delded fon
A
lieed Li4
Beginmuig of o
Linke8 Li4
end of a

poaion in +he li4,


Specfied
TrouerbingI+s
a proca of going pes oF Linke Li'a4 (36
of a Linke
all the nodes
thragh
+o +he o t h r
rd. mre are
tour p s of
Lip+ 4rom m e End aCally.
the procesk of
Liwked Li'B+.
ConCatenaton I+ ih Whth
1Singly-Linkecl Lipt >T+s
+o 4he Er me
Selomd Li3t
joining +h all nodes are hwa
of 4he 4Y i3
seX
togetherin Some sequemidl manner.
'
Tu'> operaln I t albo Callec Lihear ike hit.
splay moodes
to prr't
Each CAme Every Stor
nformoadim.

ts in whch al)
22dovbly -Linked List
one

nodes are liwked


tozether by
both
L'nks which hulp in ACCemin
mulhple
predecoMor
the Succeor
nocle CNext node) and

nodse) within the Ligt.


node (Arewoos
the orvard
Thus helps to thrauerae the lu34 in
backaard dection.
direchon omd Lo4
SHo Prev tada
3
Linked Lipt >T+ Sne which hag
33 Grtular
no bginy Omd no End. A s ly (39
Linked Lipa Can be made a Gitulay lihked List

by Simely Sertig+he addrea of the ery


noe in he Lik fiell of the Losnooe
frp+

30

4 Cirtular doubly iwkeel List It's one whth


ha beth the Succeaor
poinder omd predeCeakor poiter in o
Cirtular monmer.

Asdr
T30
nke .
nserting Nocus in iked
(38) o a79/30
Inserttng at he beginnung
o f the Lip+

at +he Encd of +he Lig4


Inserting

free poution
a+ the Speci
3 Inserthing
wthin h Lig4
Sharre

3
307Yal
LENRE LEST i'n uked
LINKED LIST
Ingering A Node AT the egi'nnung Linked
end in Sinaly
Lipt Insert A Node AT The
L+
Algo hm
INsE ATFIRST(START, TTEm) Algosithmn
Lnsert. o t (STARTr, I TEM)
for ouerflow
Stept Lcheck
StepL Check for overflow
NULL then NULL then
I f P+Y - TF PT
PTint ouer flou) Print ouerflew

Exi+ Ex i4

&lae of (Node) ele


PTR (Node t)
mallec(u
PTR (Nde ) malloc (sizeofe )
from mmory cmd
Create n e w node
acdeisres to PTA 7+em
a s g n i+s
Stepa Set PTR> Info
NULL
Stepa S PTA INFo = Item set PTA>ext
Step3
NULL e l #hm
Neyt= STAAT IF start :

SteP3
Step3 SPTR Step4
Set START: PtT;
Se STAAT PTR
Step Loc= S t u r t
StepS: Set
until loc->NetM
Repeat Step 7
nade 2 made Step6
ra nedhe
Step Set Loc Loc Mex+
After i r tin
Stepg: Set Loc Neyt Y
L2N kED LTST
LoC
Sto Fosihion in
a Noole at the Specified
Inerhng
- Singly Linked List.
o new node
PAY Algorithm
Inser+Locaton (START, Item, Loc)
After Inser+ion Check fer overflow
Stepl
IF pr== NoLL +
Se PTin oerflow

Nodemallec (sie ofWo)


Phr
ek P r I N f o : iten
Step2
+hen
Step3 If Star =NuLL
Set Stot ptr
NULL
Set Phr Next
Counter I m Porinkers
Step4: nitaliye the

Set I-o
Set temp Stevt
Steps: Repeat Steps 6 Cmd until < Loc Deleting Nede in Liwked ip4
Step6 Se temp - temp> Next
set IT4 Deletiinmg a nooe rom the Linked
Steet
Step8 Sek ptr Next temp->Ngt L'pt has three 'nakomce3.
Sek teme > Next+ : Ptr
Step 9 L Deleting the tir+ node ot
of
SHar em
+he Like Li'Bt
o
Dele4ing +he Lou noe of
2
rF
he Linked LB
After Inserhom
Specifies
Dele4ing he madle trom
SHor 3
POBition of the Livkel Li's
LENKED LIST DELETEAG NODES ( LINKED LIST DELETING NobéS h3
Nae in ngly Linked Lip+ beletng the Lat node 'n ingy Linked& Li's+
Deletinghe fivat

Algorthm
Algorithms
deleted is+ (START) Deleng (STAAT
Under
flow
StepL: Check fer underflew
Check for
StepL I f t r NuLL han
=
NULL, thun
Stat
If Prink Lik Li's is empky
Pi'w
uinkel Lst Empty Exit

Stepa fStart Next NULL hem

START Set Phr : Start


set PTRz
Stee 2 STAATNax
Se start= NULL
STAAT =
set
Step 8lement
delcted is phr>ifa Pit elemamt deluked is PTR >Info
Print
S+ep
StePS free CP). free (PTR
endf
Stoe PTA START
Step3 set

S+ep4 Repeat S+ep Somd 6 Until

A f t e r &eielion PTANext =NULL


PTR
20 Step s: s t LOC
Set PTR= PTR Next
S4ep6
Sek Loc Next
NULL 48 LINKED LIST DELETENG NODES 49
Stee Specrfiecl Position
belehng the Nede from
Step free (eTA)
In &gly Liwkad ui
Star LoC
Algorithm
Delete LoCation (STAAT, LOC
After dehion Check fov Under flow
Step L
Sstarcd f PTA: NULL them
priwt Underflow

I emed poinkers
Tni'tialze the Counher
Step 2
Se+ T : O ;
Se p r Star

Repeat Step 4 to 6 untl I< LO


Step3:
Step4 Set+emp PTR

set PTR
= PTR Nex+
Steps
T+1
Sek I :
Step
Step7 Pri blemunt deldel is=PtY>ifo Tree Bada stuciure
So
P*r>Nox+0 T s e e . A Tree a non -liinear lata
set Temp- Neyt
=

Step 8
Structure in whu'ch items are
Step9:ree (P+r) aTomged in a Sorted sequemce.

T+ URed +o xepresent hierorchial


Sto TemP xelatonmp Exigst1'ng camongst
Seeral

Acnta items.
Root Levdl o

Afte e e t i o n
A
Levt

SHo Leuel 2

Levd 3
Tree TesminologyTree hos A e t
texminology Such as+

1 Root >I+ i» Special Begnal elata


ina tree. I+ 1s the firs+ i'n the
tem
of dlata item.
hierarchutal Aromgemak
+em.
In the Ai oot
above +xee,
item in a +ree
2 Node Each data
sCalled a nocle. In the qiuen
Txee+here are 3 NoRle
Such as 7 Siblinga The Child nodes of a gien
A, 6,C, D, E, F, 7, H, T, J, K,
L,M Porennode are Called S.bling. Thy
are alho Called brothers.
T+ 8 the no. ofF
SDearee of a node In the en +able .

Subtree3 of a nodde in a uen tree are SiblingH of porent nod A.


B, C,D
The deqree of A = 3
H&T are Siblings of parent noole D
The degvee of C =1 enkive +ree shruxture i
of L = O 8Level>The hat +he
The legee Leve lled in Such a uoy
maxinmum clgree a level Q.
Degree of o ree7 the xoot node is aluways
+ree. In the given
of nases in a gisen
9Elge> It i
a Connecing Line ofP
+Tee the Nocle A mel node T heas moximum +hat s, +he Line drawn
+uwo nodes,
degree (3) so tht egree of tree ts 3 noe is
node +o another
from ome
S Terminal node A nooke with degree Calle& an &dge.
3ero 3 Calle erminal node. In a Seqmte of
loPath I H
ise +ree - E, J, C7, H, K,L Omd m are +he Source
Conselute edq, trom
+erminal nede deutinadiom node. Tn
ode +o +he
6 Nona-termina Node Any Noe who tree +he path
btween

Called non-termuinal the giuem


ecree ip not r o i A omd s.
node. 1n g n tree - A,B,C, D, EI are
, F) Cmd (E, T)
Non-+exmunal Node . A, B)
A 8 F>J
1Depth It is the maximum level o
noce in a Puen +see. In 4he 8TNARY TREES
Ony the
Yoot
+ree, +he noke A hauy tree is oa finite set of
en Sinary
maximum leuel. item which s Either mpty
data
se of Bjoint item Called
forest I t ias hg le
a
12 of Coista of a

+xees. In a qian +ree tf yoy


tuo disjoink brnary
TOOt d
Te move + yoot node +hen it belomes + h Left Subtree md
tree Called
the gion +ree, there is
o toreg. In oigh swbtree
+ree, Such cy.
foxes+ with ree
A. voot forest ib. mede Can hae
After remonng
In Binary +ree, Euery
are
Children which
moy 'mum of 2
Left Child
od Arght Chd
Known us

LeftSuetree ( ) roo
Toot

k Ri'yhk Sub+ree
ypes of Binary
+sees>
TroueTsal of a &inary ee
ary 'n which each node
D full nary +reeA
ful
Euery I+ o way
's is ViBited Exactl nC(e
Tsee
T ree i'n +he +ree
a Chl manner.
node haus o or
n a Syptematic
We uge
There are three way8 whuth
tree Noe lestRigat
-

+o +rauerse a
L- Pre ovler
troueTBal NLR
tronserBal (LNR)
nary treeis 2 - I n oreler
tree A +xaversal CLAN)
Complete
hary
Tree 'f
all Levels
are
3 PoB+order
2 inary the L o
1Preorder Trauersal In ths
Complete
fille& Ex
Cept Possibly Lef+
Compl e te ly keys as
TaaeTsal method, he vootoke is
all
+he
L0t Leuel hag
Lesel omd Leuo
0 p o b l e .
e d t a: 2 vibited tirpt, +hen +h Le subtvee
Lesl a 24 Ownd finally thi riA Sobtree.
Leds a Algothm
TreeA Tre
i'ntukthal) Until a| nodes
ase trauerBed
-

3) Perfect nary
rodes heus tuwo
CAildren Cmcd
all iwhermal
a t +he Same Leusl Stept Visit xoot node.
Leaues are
chi'd +raverae Left Subtree.
in wch all Le wl heus
Stepa ReCurgiuely
Leo Le +rauerAR Right Sobhre
Step3: Aetursively
Led
Odo6ooady
8 Sinary Seorch tree (8ST)
inery SeoTCh tree anode- buyeA birary
( +ree dota Struchure whch hag 4he folloiing Rules
L The value of +he key in the lLeft chuld or
leftSubtree les8 than the valueof roo
Pre-order +saueTaal 8
The value of +he key ih +he iht Child or
A,B,D,E, C, F, iot Subtree i more than or Eaual to he roo

2 Inoder TgauevBal (L In thi's 3The Tiaht Omd Left Subtree eoch


Subtree is
raueral mthol,
+he Left mupt also be a binary Search tree (8s)
loter
frat, them +he obt omd
Vipited
+ ri ubtree.
Algothm
ae trauersed-
Untill all nokes
toverse Lef+ Subhree
Stepl: ReCuTBively
Vi3i+ Too+ noe.
Step2
Step3: Retwrsively +roserR
Riht
Subtree.
(aToo+

Inorder Taserzoal .a, -

D, B, ¬, A, F,C, mathed
Trasersal In th'
3 9 Pobt-order the rame
Vigited Lak, hente
+he root node iz
fir3+ uwe tvoerse Left Subthree, then the
h e ToO4noe.
riSubtree omd finally
Algomthm
are
traserSLd -

Untl Al nodug Let subtree.


Step ReCuraively traerae
Subtree.
+rauerae right
Step2: Retursiuely
Step3:Visi+ xoot node.
roo
ex

Popt ovler TroseBal 1


A
O,E,8,P G, C,
Differente be+ ween Stack Cmc

S+aCkK ueue2
Collecthien of
1 I+ represe nbs the Collecion of
1T+representsthe
Lat i'n fi»t Ouk (LIFO)owkelemunds i'n Fipt Zn Fip4 ou4 (FIFo) oxder
elememts i'n
are i'nserted oamc
2Objectp are inserted amd
2 0bects
removeed from dfferent Encs
semoved at the Same
end Called
Called front omd r e a r Ends.
Top of Stack (ToS). Called
operation
I n r t operation is Called 3Iner
3 Enqweue Operation.
push OAeratn.

Called Delete operation sCalled


4Delete operotlom
pop operatn
Decseue operoatlon
In Cueue there is a
In Stauck There ib
no uastage |S
S Space.
of
o f memor'y Spoce. wouloge of memory

6plate Counter at Masmuge 4Students Stcmdng i'n a hihe at


ReCeption i'san Exo mple of Stack fees Countes i an &rample of
aueue.
Diffesende betuween Singly omd Doubly inked Li'p4 62
uLLLLIIZILLUuIILILUILllitiniLiLLILIGmITTIu nIIILULLTIIITZ
Singly Linked Lis4 doubly Linked Li'st
1 Singly Linke& List has nocls L Doubly uked LiBt hos nodes
with data fied Cmd next
Link with data fteld omd tuwo
field (foruward link) pornter field.( Backwerd ond
& forwerd Link)
Dato yt & revicws Doia Next
2I allows trauersal only I+ allow a two way
+sersal.

3 T eqpires ome L poiter3 I t rqures two Li's+ pornder


Variable (Star+ amd Lan)
variable (Start)
4I+ OCCupres Le83 memory I+ oCCUpIes more memory

S Complexity of Ingertiom amd S Complexity of Irertion owd


Deletion a4 known POitom Deletiom at known posdiom
On) O1).
((%s
Dfferene betuween Lintar omd Non-intar data Struchre

LinecAY data Structure Non-Linaor dato Sructure


1 Tn 4h'h dota S4ructure|1In this data Stsucture
The elemuntsare orgonied data t's organized witheu
t'n a quunce Such as Oy Secuece.
6 Aray, Stack, queuee& Tree, Groph etc.

2In Lintar datu Structurej In non-Linaar D.S


Single Le i involued.multple Leves are invohed,

3 74 is Easy +o 3 I+ is Afficu4 +o
mplemand.
implemam
4 Data &lemans Can Dota tlemunta Com'
be hsauerael in a be trouerAed in a
Sngle Aun only. ungle Aun omly.
SMemery 1 no+ Smemory uhil'zaon
4iled in a &fficrert 'n an £ firent woy.

6 ApeliCatorsof Linar |6 APplicatons of non-


D.S are mainy in Linaar D.S are in
APplicathon Software AyHicia Intelligece
developmaw Ome image proteAing.
Diffexence betuween Array Omd Linked Li'34 63
ZUITLILTLLLIIZTIUTUTTUU TTiTUTTZITIzIITIIzuLz

ATsay Linked-upt
Aray i tixed LSize of a Lit 's not fixed
1 Sze of an

Collecdion o
Collection of
a Liwked-Li's+ is a
Aray a
2 Homogenesus (Similardala type node Cdata 2 addres)
allocoated froom
alloCate trom 3Memory
3Memory
Stack.
heoP
i+h S4atic 4Liwked-Lit work wi'th
4Aray work
bymamie data Strueture.
data Structure .

a r e Stored i'n
Elemanks
5 SElements Can be Stored
Comtigusus memory Locohioms.
Cwy where 'n the memory
6ATa Elemanbs are i'ndepen- 6Li'nked Lis+ Elements are
dem to Each other. de pend +o &cch other.
Assay 4ake more +me, bLinked-Li3+ ake Less 4ime.
(TneTt1nL belethbn) &
( Inser+ion beletin)
Difference between Tree omd Groph 6

Txee Gasaph
1+Tree is a Collectiom 1 raph isa Collection
of nocus omd édge.
of verties/nodes amd
& T: inode, Edaes 3 CVv,ej
There i's a Unuaue 2There is no unique
node Called oot intree node.

3»There will no+


3 These Can hee
be amy Cycle/Lops. loops/Cycle.
4Repreenta datoa in 4 Represents dada Simihr
The form ofa tree Strutue +o a utuwork.
in a ht'erarehital manneY
S In raph n e or more
SIn +ree my on
path betuween
Pa+h between two nosestham on
two nedes.
Zn this Preorder, In +hu's 8FS md
In order Cmd Aostorder
TraeTbal. OFSouersal.
Ex &9

You might also like