Professional Documents
Culture Documents
De-queue
Submitted To : Mrs. Niharika
Submitted By : Riya Rana
(bca second year)
Section “b”
DE-QUEUE
(DOUBLE ENDED
QUEUE)
Presentation title 3
DE-QUEUE
INSERTION INSERTION
8 5 6 4
REMOVAL
REMOVAL
Representation of de-queue
Types of Dequeue:
Presentation title
• An input-restricted deque is one where deletion can be made from both ends, but
insertion can be made at one end only. An output-restricted deque is one where
insertion can be made at both ends, but deletion can be made from one end only.
8
1. Insert at the Front
This operation adds an element at the front.
1. first we insert 3 at the front end.
2.Now we want to insert second element 5 at the front end
0 1 2 3
If front < 1,
reinitialize front = n-1(last
3
index)
3. Else,decrease front by 1
4. Add the new element 5
into 3rd index value.
F R
Front=-1
rear=-1(at this time queue
is empty)
0 1 2 3
3 8 6 5
R
Deletion From The Front
1. CHECK IF THE DEQUE IS EMPTY.
2. IF THE DEQUE IS EMPTY (I.E. FRONT = -1), DELETION CANNOT BE PERFORMED (UNDERFLOW CONDITION).
3.IF THE DEQUE HAS ONLY ONE ELEMENT (I.E. FRONT = REAR), SET FRONT = -1 AND REAR = -1.
4.ELSE IF FRONT IS AT THE END (I.E. FRONT = N - 1), SET GO TO THE FRONT FRONT = 0.
0 1 2 3
3 8 6 5
Deletion From The Rear
1. If The Deque Is Empty (I.E. Front = -1), Deletion Cannot Be Performed (Underflow Condition).
2. If The Deque Has Only One Element (I.E. Front = Rear), Set Front = -1 And Rear = -1, Else Follow The Steps Below.
3. If Rear Is At The Front (I.E. Rear = 0), Set Go To The Front Rear = N - 1.
4. Else, Rear = Rear - 1.
Thank
you