Professional Documents
Culture Documents
Fds Ut6 Decode
Fds Ut6 Decode
Unie VI
wwwwwevww
2.
The insertion and deletion Oueue
eler ents in the stack is of the The insertion
of the
end, called top.done| the queue is done element in
www.maMA oe
Sr. No. Stack Queue 4.Display0 The elements of queue are displayed from front to
rear.
(6-1) Students
QIcODI A Gulde for Engineerlng
Fundamenials of Data Structures
6-3 6-4
Fundamentals of Data
Structures
Queue i n t M y O : : d e l e t ( )
6.3:Queue Operatlons Ouewe
Q4 Explain
the insertion
of element in queue
mplemented using
implementer
item
int item;
Q.que[0.front:
w
arrays. eue will
will alwave
of any
element in the queue always take place Q . f r o n t + + ;
Ans. The insertion out<<"\n The deleted item is
from the rear end.
retum Q . f o n t ;
<<itemi em
The deleted
We have Finaly oouraMem is 10
Ofroas
queue
40 50 inserted first 10,
10 20 30 then 20, then
then 40, then 30,
From this front
rear From this
end you can
in the queue. 50, 64: Circular Queue
end you can insert
delete the elemeent
Q.6
Explain the concept of circular quene,
the element
the insertion SPPU: June-22, Marks 3
Fig. Q.4.1 Representing Ans.: Circular queue a
in which read and front 3
int MyQ:insert(int itemn) queue
adjacent to each other. It can 40 front
are
follows. as
if(a.front ==-1)
This condition will occur initially berepresented 50/
when queue is empty For rear and front pointers 30 2
a.front++ following formula is used
a.quel++Q.rear] = item; rear
retun Q.rear; Always increment the rear pointer and rear= (rear + 1)%SIZE
place the element in the queue. front (front + 1)%SIZE
where SIZE represents the SIZE Fig. Q.6.1 Circular queue
of a queue
Q.5 Explain the deletion of element from queue implemented using
arrays. Q.7 Implement insert and delete operations of circular queue.
Ans.: The deletion of any element in the queue takes place by thefront OR Write Pseudo C+t code to implement circular queue using
end always. arrays. S SPPU : June-22, Marks 9]
50 60The number 10 gets deleted logically Ans.
10 20 30 40
That means queue is from front to rear only.
front rear 1.e. from 20 to 60
This much queue
insert function
will be considered ososeee
i.e. queue is
from front to rear.
Fig. Q.5.1 Representing the deletion void Queue:insert(int item)
QicoDD A Guide for Engineering Students
QIcOD A Guidefor Engineering Students
6-5 s of Data Stru
of Data Structures
Structures
Fundamentals of Data
Fundamentals
Owewe 6-6
i f ( f r o n t = = ( r e a r + 1 ) % M A X )