Professional Documents
Culture Documents
Data Structure
Data Structure
Data Structure
Front
dequea enqucue
Queu
Arroy Tmplementation ef
As with Backs, any.im
implemetatiorn u
queues like Stacks, both the linked dit
and avag
ag implementation give o() runnin times
and back .
the Array[bacx] X
Frond baor
back Front
Front
back
Attes dequew, which retunns (3)
a4
back Frort
’ Thu tot makes the
queu epty
Some p eqrame
Sene dijecnt ays of repra oti
the {ront and back queu.
(Reje tent tor qormulas)
Opetions on Queue
3)
dequee C) : deletes the rort elernend and return
ts are
4) emptyco: Tt
empty and Yetnn talse (o) i the
queu u not empty
6) T Teterns tmueC 1) ie the queu u
qul and eturn aie (o). R queu
not
Enqueue opexation :
lo o30 40
Fuit Quu
Front Reor
(
Empty Queue
ER
3
- Queua with 1 elument
FR
Dequeu opeiction:
Agie empty quee, quea with Ielement . Ateu duqueu
30 do
- Atter DeQieu to
F R
Reas
Frond
Applications ot Queue
Serve
First come first
Aueue maânly reared
when Jobs ase
Subritted to a printer. the a
Thus Sent
job sent to a
ordex of arri val
ronged queu
Pintet te placed a
qu
ueuing theey dea with Cormputing houw Jorg
Users enpect to coat ine
Round Robin techrique for Procesor schedulie
implemerded using queues
All type ot Customex Service (dike
ailedau
ticket Teservatton) center sotwte g
derigned
are
uing queuel
Other Application ot Queae
- Batch processing is opeuting gtem.
To îrnplernent prierity Queues
|horty Quedes Can be used to Jort the element,
cuing Heap sot
( Reier tent tor more Point )
UNIT- Y
Tiee s
mon- inear dota
stuctwe
that used to epreserit
blw n dividual data tems tievasichal selotionships
n
A Tree & a ideal Speacialüed torm for Cvganur9
data tructwre or Storrg
vepresenting hiesar chicat data.
A Tree Can
-
be theoriticaly detned
Set one mere data tems (or nodes )
Such tat
o the oot .
Bran ch s he irk
" Branch ! between
Parent and s child.
Node : Leve L
Level L+I
. Heigh! oY depth :
Heighd on depth o
depth os a tree
deined-theto tree
be the
rnairnum
(1
level o any
nede fn
heigtd 1
climbinq: (6) () depih 3
The Process of traversinq the tree fm
to the Yool called cltmbing the tree
caued the
descendinq the tyee
to the dea
Terminolqies of Tree.
TREE
Root
Level Parelode cimbing
Branch
Non tesminal nede
levet (B
H
deten
Levet 3
F, G, H are
D,E QTe
Sibilings
(Leag Note
oT Texinal Nocde)
F, G,H)
(B, C, D, E,
Subiree o
B ( D, E)
Subtree
tree i
Complete binary tree T al the nodes of a binary
tree Consuts o tw0 nodes each and the nodes at
the ast level does not Corsut any nodes, then that
tree Caled Complet inary tree
Can be obseved as max, no. of nodes on leve
binarg tree is
o°8 a no. Qi-1 cwhere i i
of nodes de pth
man.- no. o k u whue K
Binay tyee. Skewed Binavy Tree
A Root only one Side )
t chitd Rightchildtd
Righe child
D
leaving the
positiorn ,one Position VacantE
30
Arsa Reprasentation :
30
3 5
The seot elemert
elemert u aluways stored in position
1. The tet chid ot the node i stored
in the position &i nd ight ch-d o node
Stored Pasition
Hehce the tollouinq ovmula Can be sed to
iderti the parert, dejt chiid and igha chiidnode
oo a
lejt chitd.
tonsists h -! ndcoating thue ü
6>K * Condition
Q(3) >
5 5 salilies
-Right chtd i | > a(3) +) z
Position 4 4 in the arry Q0.
binary tree
inked Representatlon of binary
Ih
-In inked Represerntaton o binay trees, înstca
inteo:d
aTras. pointe ar Used to Connect
ave
the Vat-
nodes o the tree.
Henca, each node of the binany ree consut o!
three parta ingo, legt. ght
-The Tnjo part stores the data, det pat tote
-the address of the dett child.
Right paet stoves the addhes of the ngh chid
30N
|lo