You are on page 1of 19

8 i n a Y se0rch is onla opplicable ahen

*UnitTL* Sopted.
iven aray s
eaTching is a technique of ffndira an elem iv This method makes (omporrs0n bet ky element middle
ent in a iven s t of elemenis element of on dray
V Since elements ove sorted, then Comporison moy be
Continued with 1eFt /ight haJf of elerment
Q1 Sequencial Lineay search vi] Left haf elements con be selectd by C-1
- T n sequencia search
elements are examinedl v] Pght hauf elements con be select by
sequenticdly starting From First element
No Of viiThe podcegs of selecting left /7ight hadf Continues
CompariSO nS for a
not Fixed. Tt Sequencia search is until the elemernt sfound o el ement is not there.
element is at
depends on the location ot eemente Best cose ouon thm us need 1 Compazison if
i'* position then no of (omp. (Space the element is Found at centde.
ariSons will
berequie to Search element CompleiT) Timing
oC), Complei b
a
Expected no of compaiso05 for su ccesstul seagch Avemenne uwosst cage The w0TS t cage behaviduT OF
C P + 2P t.+ OPo CTime oino Seaseh a
Camplexity d algoi thm hay
C
2 Timing Complexity o(log,
Time Complexity of sequencia seorch = O(n) Seay ch ing element 2g in aiven
I has adwys Constont spatial om plexity o0) 2 3 4 S 6
29Tay. (Binausearch
Index
elemen t S 25 29 30 3S40
@ Binary Search
0 2
i) ineo Search hay time complexity OCn) Such
agoithms are noot sutable for searching uhen Element to be seorch
no. of elements is lage in that cage binorTy
ke s .
key aTay [e] . 297 25 half selecteo
Search eshibils much betBer dimina behaviou
inde 678
) IF Jinea 1million compo Sons
search needs
elements 29 30 35 40
Fo 6earching an elemen in an amay having. 1
1million elementS, search
uhile binary 7q I5 C6
e s Only 20 Comparisons for some task
kay < a[c1 29 30 lelt balf selected.
No. oF Cam pon iso ns for 20 CImillion)
Tn odex 5 element is fbund
Scquetid /Linear search 2 (lm compani$ons)
seach is
element 2
SeaTch only 20 Com porisons. SuCces feull.
Bina 5 C 5 S
9 220
e s eayching c elemen 6 n 04Fibonacci 50anch
aiven d}}ay a
based techoique
Index 2 fibonacci search s compo 1Son
6 searCh ao element
numbers to
element 29
that uges fibonacci
15 25 30 5
In a soTted aToy
here oF 4 eleme
J 8 C: 4 aiven a sodted aay TYC cizen
key alc.. j= C-1
hene O C:T oF seasched
J 3 key 4 afe1. J C-I 69
o be then
hee element x is io aray return
J -O C O.key xal... CtI TF pregent
z if itis not then etuTn -I
J O, C tlement nct found the index of
Iput, arLJ =12, 3,8,1o = 10
ndicates , element not founo. output 3 indes cf nc 1c)
C difference betn inear search bin0sy seugeh
Iput, o [3 , 2 , 4,5, 3
-1 element net found)
outpub .,.- (
Lnea sec ch inary searcb Time of Frbonacci seasch O(Jegn).
Complety
Simple agothm Compa7 itively Complex
adgoaithm Q5 Sentinel seorch i
An exta record nseted at the
end of an arTay
i) t equires /2
O/2 ) It requires log(n)
is called ag
sentioel. The speed of sequencral
ompari Sons. CompaIS0nS. he key
search can be improved by StoTin
ii) Data is need ) Data s equ red to be eaTched aut the end of the dy.
dTTy.
be Soted be sooted
iv) Time Complexity is iv) Time Complexity is
O(Log n)
v) Ttezeutive algosi thm v)Recugsive alaovithmn.
S0oting S a poocess of ordering a list
in
of eemen
ascend ing / decending os der At g 2 3 4 |6*|8|1o | 12|isg
SoTting Can be divided | is T5
into fous9 |2 3 4 6 8 |1o 12
)Tntesral sotiog 91o12 15
)
Extesna sor ting fass1o 2 34 678
8ubble sot, insertion sost 4 merae soot are stable 2 345 6 8 |9 |io12|is
ahere quwck sort 4 heap Soat ave unstable
Paus
The Vedy eos4
elemnents -1 Inseti0n Sot.
sorting algoithm is sard to be steble f
ccer no.of Pas95 no OF
SorHing, identica elements
appearr io saMe sequence
as in the omgrnu unsoTted 6 t
2 Bubble Sot 8 most
4 the
Tnser tion sot 7his method s one of the sîmplest
This algonithrm is one of the
simplegt dgorith Popular Soting methood
wrth wor9t Case time Complesi ty otn2)
Simple implementation.
Tnsertion Sost is erficient for sma values est case spce Complesiby C )
wOTS cage behaviour OCn*)., time complexity Bubble s0Tt to
Best case behauioUT shoo output of each pass using
OCn). Space complexiby e
in ascending order
OC) arnge Following ne-
1 Sot the list usîng Insertion sodt no.oF elemets
No.oF passes -I
initial list
7410 6312|8|2|is|9 5 30, 87, 76,65,49,32, 19,7,0,-1*
Pass
6S 43 32 13 *
0 8 n6
Paus 2 Poys - 19
65 43 32
Pass 3 19 -17
43 3
-

8 6 17
.a 19
Po4s 76 65 3 332
8
46 65 43
o4s 3 71o 1a 21595 84 65 43 32 90 19 -17
Pags6 3416 65 43 32 19 -17
1 12 82519 5 76
8 43 32 19
6S 49 32 o0-17
6 6S 43 32
Paas 2 8 6 65 43 32 9 7 O -/* 90
3 Selection soat pre ( rmplo/i o ()
s00t USTO8 selection Sort
show al the pagseg
6 65 43 32 9 - 17 12-&& in decending orde
34 78 65
90
9 78 65 12 -8
Pass 3 43 34
32 19 Initiod a11ay
12
65 43 32 19 + Pass 8 3 3465
Pass4 65 43 32 19 -

Pass 2 +3 65 12 -&
14 76 97 8 3
43 32 19 O -17 fas4 48 65 34 12
65 68t 3Io
78 65 34 12
foss S 43 32 19 O -14 65 76 27 Pass S
32 19 O -1 43 65 76 87 S0 afls ewery pais
e. sost the followiog 4 show Status
Pass 6 32 19 uing Selection sort 34 7 8 65 - 8
-1743 65 76 87 30
- 1+ 32 43 65 6
19 81 34 9 78 65 12 8
1nitiaul omro
Pays 19 - 17
32 43 30 65
65 768 Poss 8 34
O 32 43 6S 76 87 786S 12 34
- 1719 90 Pa&s
Fass 8 -
19 3 43 6S 87 Io -8 265834
Poss 3
4 65 76 27 90 -89 12 8 65
O 34
Pos4
- 8 S 12 34 6S
19 3 43 6S Poas 5
Pau9 o -
719 32 43 6'5
-17 0
.Sorted aney -89 12 34 6S 7?
wOTSt time COm plex iy
SPace Compleay OCDa)
4Quick Sodt o(Aogo)
Quick so7t i9 a Divide Conq uer agoTIth M. IS8,-2,-4, 12,.,16, 21, 20
element as a
Tt picks on
pivot patitions the
8Iven aray aTound the picked pivot (Here i2 AoT 2415 x $0,
We con 50, 16 16>1Sv
aLs
peak FiT6t 1last / any Tonolom element
Piv ot to Sort the amay Here j I<15 iexceed
The key Process OF qwcksovt is a
n
puTton C). Bub Hee index of i 1G s +
8ivern aray choose element as
he pivot index oF j= 1 5
Put at its correct position in Srteo Here
amay
Put all smal ler elements than before e2
Hence we haye to interchange Value of
Put adl areater elemens aFte &,
wth phvot. (is)
1 aduoys greaber than pivotJ,j i6 smauller than pivot
S07t .
e he given list
using qwck S0Tt 8 2 , -4 ,12,2516,21, 20
5,8 Pivot
,20,-4,l6,02,O1,12,21,-2 Left partition
Jets take 1s
Right p7tition
element 5as pivot
Index 2 Je selement 1 Pivot 16 Pivot
IS,8,20,4,16,2,1,12,2, 2 3,-2,-4, 12 ,2
i J
16 2, 20
(i vaJue is
àzi HTSÍ TTI 4 jT Value is uT .-4,?.2,12,2
STCT UTi Jaer 16,20,21
they eschanatd) Here i>j L
Heae i8 o 84IS 5o, I 20
Pivot interchonge J
2015
Here = -2 ,8 ,12,2
-25 eft
Right P
w e have to exchonge 20 2 . i Pivot
-4,-2,1 ,18). 2,12 i4Pivot Conditions
5 8 , -2,-4, I6 ,2,, 12, 21, 20 4,2,', 2,8,12 ultiple patihion e
CHene i: -4 HOl1 -4
ISSo, S 7 IS Sorted No. ove
Here J: s
21.'but 2I Pa 2 15 so, 12<15 ,
e houe do - 4-2,2 ,8 12, 16, 2O , 21
echourge 612,
e Qufck sort
Sort followiog no. ing
5 ] Merge Sort
25, 82, 13,23, 38,4,65, 88 , 21 sorting algo0ithm ahich ha
TL is vexy effecEive
optima no of compaTTS00S.
25, 82,7,23, 28.9,65,88,2
we have to merge to soted lis1s
In this
nto ooe sodted et
, RERKIZAASeSKBRI thas c inear +ime comp lexity
s0t...
25 2,1,23, 33,7,65,88,82 -J e stae the following ging mere
85 45 05 9
55 34
S , , 17, 23,7, 38,6s,88.82
split 55 4S 34 05 99
Here i>j Hence Pivot intrchonge j..
7,21,17, 23, ,38,65,88 ,82 plit
left
,17, 23 38, 6S, 88 ,82 Menge 0529 L799
4,17,2,23 L5S,&5 , 4 5 134
38, 65,82 ,88 O5,6789,99
Menge 1,34, 4 S , 5 5 , 8 5
PMerge 05,11,34,45,55, 67,85,89,99
The sorteo no.of Owcuy,
4,17 2l, 23, 35,38, 65, 82,88
6 ShellsOvt
This method makesrepeated use oF TnseDhon
then
: 4 2
Second pos
SOTt to mabe 2
S to be 2 steps... (we haue gap pur)
oF n elements SOrted,
T an aray
USin shell sovt thenn i'ncement (di choasen ' 2 0
beFore evesy pu8s
odi shoudd diminiSh
dishoud be less than ( 8,2) (2,8)
fy the laßt po8S di should 1.e
coith eery poss
(O,4)
(2,5)
Ex. Sovt 1st Shell sot.. (4,14)
cg1 S ,3) (3.5)
the siven usîng
8,3,2,11,5,14,0,a,3,4, 20 (14,3) = (9,14)
i 5 n oof el), (3,11)
(9, 20)
Fist pass 56teps (ue have to make paiy adter gap
of 5 pou'o)
Aray after
20, 9 20
2 , 0 ,8,4,3,9,5, 14,11,20
(8,14 Aaein chetk tr i
(3, 0) (o,3)
Sunpping pactr ble /4 (2 gap pau
es Possible
(2,9) ,3,3,5, 14, 11,2o
(1,4) (4,10)
(5,20) (2,8)
Co,4)
Ary After 8,3) (3,8)
4,3)
(3,5) After amrc
8,0,2,4,5,14,3,9,11,20 (4)
Ayai'n Chak or (5,1)
Suopirgis pastible "(5qp paYl 2,0,3,4,8,3,5,14,11,20
taun Suopping posSible to /4 (2 gep put)
A casetbbyf
SoTting Algoaithro Bastcage w9 caye
2,0 3 ,8 4, 20
Bubble Sort o(n2) oCn) oCna) Stable n-1
(2,3
(0,4)
(3,8) Selection sort oCnoo)o(n) Stable n-1
(4,9) AFter amay
(8.5) (s,8)
(9,14) 2,0,3,4,5.3.8,14,1,20 s Tnsetion sor
(5,19 OCn) oCn) o(n) Sble n-1
(14,20)
Agcun Cheuk dhathr Suappirq Possibk for 4 Qwck sort
(294p pcui8).. o(ndoar) o(?)nlogn)| Unstable lo
Third pess Hee / 8 1 (8ap put).. SPleeeesoTt
o(nlogn) onlbgn)|o(nlogn)Stable lgo
20O
0,2, 3,4,S,8, 9,1,14 , N.F
Kaud ix Soot diits
Stable in the
ad ix
te hone to make 3 time s0 OCo) (n -1
oCn)oC(n) a7gesF
numbeyY
Aftor aray
O, 2,3, 4,5,8,9,, 11,14,20
Head
*UNTTN
1] AYay Linked ist BOoubly Linked 1st
inked list each node holds two pointer
Linked I s t s a In this type oF
)Aray is grouping oF
data elementts 87ouP of entities ffelds.
quvalent data type. Called node. Node Head
ineludes data 4 address.
2 It stores data elements 21 Tt stores elemen ts
in memory Zone. andomiy in memo
CondiguouS memovy zone) Zone Cirular Linked lst
In this type fbst t los elements a r e ajacent
The data elemens ane Storing the
8] The elements OTe 3 A linked s t Cen made crula by
not dependent on each depndent o each d ddress of first node to the loast node
other other.
47 The process of accessing 43 The process of acessingA
elemens tuke les time. elemens take more Hme
5 In Coe oF Ara y. 53 In caje of linlced list
memo utiliZution rs memorY utili2oution is 62wite algosithm to pes Fo m Teverse opêtati'ons on
Singly inked s t
ineFFective effective. the
A
lioked ist con be rever sed by changing
size is directfon of the pointer agaun again
The memoy 6J The placement of
FPred 4 it is not possible elements is aliocatedd
linElist
t change it duaing duding Tun ime. S HAH iginad
oun ime
ink lst after rwer
OF fost oode.
Types Of Linked list
Singly Linked List AFtes eversa of
su ccessi ve
nodes of n d node
Tn this type of linkliet two
each o ther in
st ae linked cwith
the linked Lfnked st after
scq uencial manner, eversa of
Movemen in foruotd directton is possble. Xode.
Jet 3
pointe Vadable P.,
P elerences Iinked g t e v ens eod so for 03 Lnked list a an AOT
31eto
4o linked s t to be
Pointe ) Linked s t S chain oF nodes herre each nade
deversco (on3ist oF tuo Fields, a data Field 4 addrass field.
points net no de to
2) Data field holds the actual elemen on he list
ahee next oddress Field Contauns the address oF
Initi vaJue
of P.2 T next node in the list.
entive linked ist is acces sed hom the
3 The bde in
Tefereoce vaTiable frsF that points 3
the est
APter rever- contains
3ing 1node node
The next add ress field of last
P +nwl ndrcaks
specia vadue called Cus null
of he i s t .
OT3gna s the end
,a linted ' s t i
like a stack o7 queue
APer mavirg 5J Tust
P. thef a data shucture.
forwoe
AOT Abshract data type..
from 0LL
CFunctooCode foT eversing singly linked ist 4 wTite alaosithm fore delate node
Node) a
Deletio n oF
P NULL 9 head T 9 Next
Whfle (nade to (successor of P)
CProdecess
oF
oT
1 P) be delaked)
rever se the node poinbed by ahen a node, pointed by P is to be deleted then x be
-
1 P;
next ts prodecess oT node 4 Y be its successor nede .
move P,qr fotwOTd by a link dt æ should be set to
node Right
link at should be sel to .
P:9
Releasethe memo1y allocated to the node P
Y
Y neet Head
QS Explain polynomfal representcut ion using linked
's ith an eAample a ](o.b.(c.d (e.g).h). F)
Head
A polynomial Pa) of degee nis defined by
the epress ion
PCa)= aoa+a,a"+ . +an
uhere an is real no.n fs on integes.
A polynomial can thouaht oF as the ordeyed list
GLL.
oF non-2ero 1emsEach besm ts 2-Euple Kepoegent following poly0omral in
us1ng aenesalize linked li'at.
Contauning poeT 4 Coefficient .
+ (9«+ )
y°(Se+ 9e) + y (5t t 6)
5 + 62-92 Pawes oefFicient
Jet i s only Vaaiable then
(fouwes, coefhcient) (3, 5z°+9a)
This polynomicu Tepresented
as
(5e+9e) is coefficient of s
(015)(2,6),4.-9) 5e+6) Coefficrent of
'. (1, 5sx46)
Hence the linked repesentation oF he polnomiou is CoeFficient of y (0, gz*+7)
(32+)
P
0
5 62 -9x1
I-319A
@6 Generlized linked list CGLL)
sequenaaa elemer
denoes as
L (, da da.... Jn) -ES-19
ahere n o . of elements.
Flag0 (next pointer)
Down Next
Flag dataPointer Pointer I(dovn poinier)
cTetT gd Be+Ul (lut coefticeat
Ocute: Atom
3%+5+ *x) y3+ (3 + Sx47a) y6 + 6xy
only ene element/atom then 0- Nest pointes . a,b
s e t of atom 3r+537x) y°+ (3a1 + 5«+*2)¥+ 62y
b uae - doon point ea,bCc,a)e)
G ) Memoy allocation UNIT V
the process by which Compuber Prog
Tt is
A stack is a logica Concept tha Consists of a
ams services aTe assigned with .
Set of similor elements.
Physical (Nirtua memovy Space
i) Garbage Collection Stack ag an AOT
1
Lt is 0pposite oF memoTy allocation. Stack is a LIFO structure
an cay.
be represented uging
Garbage is memovy occupied by objects 6 tack can
hold elem ents
A 10 arTaY con be used Eo
that ae not in use by the poogTom.
A collecto collecte OF a sta ck
it to
8gabage gosbage t Tetums
Another VaTiable "top" is used to keep tra ck
genera ree memary oF the +opmost element
OF the index
associated with object stack
Operations
Q8J Advan ta ges Of lnked list ove 0ays
void initialize CStack *P) stac*
) An aray is a linear colleckion of data stack aS an empty
T+ initializes a
elements while a linlced s t ie a lineai
(ollection of nodes. int empty (stack *P):
2) Linked list does not allow vandom access Function checks ohether stace is empty.
Stack
oF data. reburns I or 0 depending aheher
9 emptY oT not
3) To lioked list nodes can be acce ssed only
in sequentiau manner.
3)int Full (sBack* P):
uhether steck is full.
4) Another advantage of linked list oven asy tunetion checks
hether stack
is that , we can aodd any no. of element o returos
is Full
I or o depending
the list this s not possible in cage of
4 or not.
aruy. 4)ot PoP (stack*"P): The function delete s
Topmost element from the stack
5) void push (slack *P, int z): The function
nsets element 'æ" onbo the stack po1nted
yP
C Applicabions o stock: 1) PenmitHed opeo nd s A,B,C,D .. meons ony
Uses Tea oumber.
a)Pesmited operator3 ,,?,/,^
Expession Conversion
a Infiz to 3) Blont are perrnit hed in the epression
postfix
bTnFiz to Prefix. 4) Pamenthesês are permited.
cPostFix to Tnffx FreFix 4 Pastfix ex pressions can be evaluated
d] refix t InFix toSter in Compaison to inFix expmess
íon
becoz
any brackectg.
we don't need to process
Tt can be used for systemathc memo
monagement Algovithmn
is opeond push it to stack|
Step TF choracter
3J t can also be used to Convert one then PoP too
form 23 IF chara cter is opegator
oF
expmession to onother form. Step
elements Prom stack operate on these
to operator 4 push
4 Function call elements accding
buck to stack.
the resut
5 Parsng until he
6 Simulation of vecuT910n Skep 3 Slep 1 4 2 has be vepeated
result/end thos rea ched
oF
The ResuWt is Stored ot the top
Q3J Waite an
algoaithm for PostFix Shep 4]
with on example.
evaluation the steck,
eburn it
In PostFix writlenne
expYession operatoS are
after their operonds . Step s END
t o eg. ABC +* D/
Hepe A,8.C,D oTe operonds Push Insextion oF an elemenF
+ Cre operatdrs.
Pop Remoual of an element
Allow
Permm ite d
losel bracket .
farontheseg )
(D

13 +

(D

*7
osth fo infP # UNE *
ABC * Ef^/G +
how mudtiple Stacke
(an Store in
QsExplain
3esins a 12-T an orYay
To Imple mênt multiple stacks ina single
A 6-C EF /G+ Yoy then e have to div ide the aray
in K slots each has size k+Fix the
AB-C EF^/G+
slots fo diffesent stact9
A (B-c) EF"/ Gt We can use aTY o] to any[o/k-i| for st stackk
A (-c) EF Gt a C/k] to 0 2n/k-1 2d stack
Fo7
A (6-c)/(E"F) G+ SO on.
to undeas tand,
but
This method is easy
A(Bc) / (E'F) G th ere is poblem oF ineffrcien t use oF oway
Space.
Qi) ahat is Tecursion A stack push opetaton may Tegult io S}ack
Recuision mean Ovea flow there is Spa ce avalable to
even
of itsef.
defining a
problem in deym aYC.
a9 Explan use of Slack Fov recuY$i0n
Qs] Infix to Kefix ...
Recuys ion is implemented usinq stack
be COz activation vecov ds are to be storfd i0D At 6c) * D+ E^5
LIFO OTdes (last in FYst out) ..
Step 1 Reverse the e
as)uhat is backrocking I t It is a
techníque SaE+D) CaB+ A(
baged on
algo. to solue
Psoblem.
es TeCUTSi ve ling to find 9o
cal Step3 chonge ar'
C4) Explai n Backtrecing uging8 n-Queens
If
Poblem S E +DACn B A)
a ueen iS unde
attack at a
posiHon to Jao
ae backfrack
$ change the
oy to urent Posrton posi ton of the queen
,le repeat this process until l
placead
N queens
dne placee suus
Ho postTtoos)
Step (snvedt expoe ss1on Stot 6 Queue
S1ack PostFix
Expession (input)
5 T 1Explain linear queue ciCulo queue ith
Nwl
5 Suilable exomple
P)
5E [ Linear queue
E
SE It is inear data shucture that Follows
the FIFO Cfirst in Frst out) orde.
5) SE"D
SE"D
SE'D
fontufeeT
3) Enqueue De queue
ReaT TaLU
5EADC Rear
S E DC
front
t (^
FIFO Ovder
to) SE'DCB3
+(+ 5E Dce (23 Cculas queue
+ (+ sE Dce"A T+ is voration of ineoy queue in ahch
13) 4.(+) SEDCBA+ Frontyeay ends a1e Connected to each
4) NWl Nul 5E DCB^A+ * + other, it optimizes he space Cuas tge
fsont
iority el ement a daoll
AK+ (feT sep 13 to )4
20
slep 4 Reverse the expessi on 30
S040
+ tABCD" E5
Reor
Linear ueue CcuJor queue
4Cueue ar on AOT
)Avonge daa in ) Avvonge dala i uee is linea1 data shru ctuTe n hch the
CIYCWoY 07der ngertion are
deletion epeTahions perfomed
a two diferent ends.
) hont eo ot 2) font reay end -The inges tion is pes foTmed ak one enci leleti
Seporate oe connected on is pesforrm ed at another end.
In
3 Tt equres more queue Dctta sucure the in serhion opeT
3) 1t eqwres less aion is at a
memoy spa(e pes fo1me posiHon
af Re nown
memoY SpaCe The delekion opeTation i5 pesFoYmed at a
- .

4) As Co mpoySon to
4) AS compan9on to Positon Enown c s Tont
itisinefficiennt tis 5ufficient -In
queue Oata Structure ,the inse tion 4 delehion
peraions ve perfovmecd baje on FTFO 07der
opesations on a Queue
ovea
Give a dvootoqes of cotuay queue
)enQueue T o insest an ele men ts
Lineaur queue. 2) de Que ue ) To del ete an elemens
I n cincwor queue element9 Con be 3 disploay c) Te display the elements
insertel,
easily aheseas in case of line0Y queue front Rea
insextion is not possible once the eor
eaches last indeæ .
2) In CIYCwa s no
queue there wastage oF 5 Eplain ciYcularquueue usina link.lsE.
memoTy 15 used
Mem 0 proporlin a CYClar queue is bettey than
ineay queue
becoa thene is no
Valuable e f fectfve monne a memY waSta ge
t linean queue. Compored -Linked Iist povide the facilitY of
dynamic
3) 0iffenence memory al locahion s0 it is easy to
-
cr eate,
Points dJ when we implement cisculo1 queue uSing
linked ist t is
similo to circlay linked list
expect thene ase two pointeT hont 4reay 'n
ciculay queue tuhere ciycula linked list has
Only one pointer Head
deQueue with inset delete ope-
QExplain «7] PioTily queu
I is a special type oF queue in uhich eac
Tations pedfoom on it
element is a s o i ated with a priority value
A A queue is a dada shuctune in thich
And elements ae 5eved on bagis of the pnint
ahateven (omes First wiI So out fiv9 t .Highe pioyiby elenents ore served First
tollows FIFO o der ,
Element
Inser ton is done from one end in queue with Dequeue
koown as Highe9t 8
Tea end /taul, oTity
Oeletion done hom onothey end of
know as qu
-
hont end Head
The Dequeue Stands For Double Ended enqueue
-
queue
Deque Is a lineay deda structuve hex the
nsen tion del eHon Q8 Implement priosit queue uSI Dg adys?
opesatio09 ave pey for meod
trom both ends. ioriby Queue is an exension oF the Queue
- There
are Douta Stru cture where each element he a
ypes of Deque Porticuloy priorty associated Cuith it
O Tnput nesticted Queue
on
Tnser tion operahon con be pen Fosmed at only Operations Riority Queue
one end ,ahile delehon Can be pedformed enqueuet) This funchion 1s used fo insert
both ends. new data in the queue.

Inset i) dequeuet) Thls function Temoves elenment


t h he fom queue.
delete delete highest prioity
i Peek C) r top)This function is used to get the
output vestnicted Quele 3 Highest priorib elemen in queue.
Oeleton opeaaion con be pes fFormed atonly one t)value 4 2) Riovity of elemeh
.every element OF h e aroy uill stome
end, ahile i'n sertion Can be pen Fovmeol om steps oF Tmplementaton 3
Define structure with 2 members value 4 Arioity
both ends
an of Shiucture uhr'ch heus a fxed
2) Declare aray
Tnset
1nseot Size morSixe
si2e deteamine the si2e of the pa iomity
3 Varicble
delete queue at any instance.
si2e =-1 indicates that the aiven
Initially
queue 19 empty
One
Plultiqueue T assiqns moe Ihan
eceive aCket queue moe than One
10 Applicalions oF Cueue
tronsmit Packet queue to on intex tace. pío7ity
)Prim'5 agoth
Queue Jts imple mentction Can be done uGina
There ae 2 types ot io1ty
C
() rioriby queues.
Ascending ovdes pioiy ueue
element 2) Oijkstro Shories path agoithm
element 6 7 101 uith
wth
(ouest
Highes
hioviy 3) Priovity queues are used fo Sort Heap9
Poionity
in
i
4) Priority queues are used operatinq
(t) es cendin oyder prioviby queue
Syskem For oad balancing
are uge d in huffmon odle
1o985 2 elemen 5) hiovity queue
element CuTh
foY Docta Compre5si0 D
Guith Lowes
Highest Ariosity
riory A
F09

You might also like