Organ: Relatronhip
Organ: Relatronhip
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
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.
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.
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
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.
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
Empty ueue
operadiom on Cueue (23
T o insert an &lemont in a ueue
+ue
Read 30
O 1 falag
Elae
UEUE (Dota Structure) (
Selete oeratron ueue
l o Ro30 ma se 3
R2
F-0
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
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
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
ts in whch al)
22dovbly -Linked List
one
30
Asdr
T30
nke .
nserting Nocus in iked
(38) o a79/30
Inserttng at he beginnung
o f the Lip+
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
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
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
I emed poinkers
Tni'tialze the Counher
Step 2
Se+ T : O ;
Se p r Star
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.
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+
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
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 -
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.
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.
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.