Question
What is a Dequeue? Write algorithm to perform insert and delete operations in a Dequeue.
Answer :
Word Count : 754
___ ____ ____ ____ _____ ___ ______ ______ ________.
______ ____ ________ _________ _______ _______ ______ ____ ________ ______.
___ __________ ____ ____ ______ ___ ___ _______ _______ _______ ____.
___ _____ _______ _______ _________ __________ _______ ___ ____ ___.
___ __________ ______ __________ _____ __________ ____ _______ ______ ________.
_________ ___ _________ _________ _____ _______ __________ ___ ______.
______ _______ ________ __________ ______ ___ ___ __________.
_________ _____ _________ _________ ________.
____ _____ ________ ________ ___ _______ ___ _________ _________.
____ ______ ______ _________ ___.
_______ ___ ______ _________ _________ ________ ___ ________.
____ ____ ________ ___ ____.
___ _____ __________ ____ ___ _________ __________ ___ __________ ________ _________ ____.
_________ ___ __________ _________ ____ __________ ______.
________ ________ ____ _____ _____ _______ ______ _____ _____ _________.
_______ ________ _______ ___ ___ ________ ____.
_____ ___ ___ ____ ______.
_________ __________ _________ ______ _________ _________ _____ ____ ___.
_____ ___ ________ ________ _____ ________ ______ _________.
_______ _____ ________ ____ ________ ________ ____ ________ ___ _________.
__________ ____ ____ ___ ______ ______ ________ _______.
_______ ______ _______ _______ _______.
____ ___ ______ ____ ____ ___ ____ _____ ___ _________ _____.
__________ __________ ____ _____ ________ _____ ____.
_______ __________ _________ ____ ________ ______ ________ _____ ______.
________ _________ _________ _____ _______ _________ _______ _____ ____ ___ _______ ____.
__________ ______ ___ ___ _______ ___.
______ ______ ______ ___ _____ _____ _____ ____.
____ _______ ________ ____ __________ ______ _______ ____ __________.
______ __________ __________ ___ ________ ___ ________ ___ _________ ________ ______.
__________ ___ _______ __________ __________.
__________ ________ ______ __________ __________ ________.
_____ _______ ______ _________ ________ _______ ____ ____ _________.
_____ __________ _________ _____ ___ ________ ___ _______.
______ ____ ____ ______ _________ _____ __________ ___ _________ _________ ____.
_____ _____ ___ ____ ________ ___ ________ ______ ____.
_____ _____ ________ ________ ______ __________.
________ _____ _____ ________ ____ ______ ________ _______ _______.
__________ _____ _________ ________ _________.
_________ ____ ____ _____ ___ _______ ___.
__________ _____ ______ _____ ____.
________ ____ _________ ______ _________.
_______ _____ ___ ____ ____ _____ __________ __________ ______ ______ _____.
______ __________ __________ ____ _________ _________ __________ _________ __________ ___.
_____ ___ _____ ___ _____ __________ ______ ________ _____ ________.
____ ________ _________ ____ ________ ____ ___ _________ _______ ______ __________ ____.
__________ _______ _______ ______ ________.
______ ______ _________ __________ _________ ___.
______ _______ ________ _____ ______ ____ _____ _______ _____ ________ ___ __________.
__________ _____ _______ _______ ____ ___ __________.
_______ _________ ___ __________ __________ ________ _______ _________ __________ ______.
________ ___ ______ ______ _________.
___ ___ ___ ____ ___ __________.
_____ ______ _________ ___ ____ _______ ______ _____ _________ ________ ______.
_____ _________ ___ ____ ______ _______.
___ ________ _______ ____ ___ ____ _____ _______ __________ _____ _______ ____.
______ ______ __________ ______ ______ _______ ___ ___ _______.
Skip in 10
A dequeue (pronounced "deck") or double-ended queue is a linear data structure that allows insertion and deletion of elements from both ends, i.e., the front and the rear. Unlike a standard queue, which is a First-In-First-Out (FIFO) structure, a dequeue provides more flexibility in managing the data as it supports both FIFO and LIFO (Last-In-First-Out) behaviors. There are two types of deques: 1. Input-restricted deque: Insertion is allowed at only one end (rear), but deletion can be done from both ends. 2. Output-restricted deque: Deletion is allowed at only one end (front), but insertion can be done from both ends. Deques can be implemented using arrays or linked lists. Here, the array-based implementation is used for simplicity. Let us define the basic structure of the dequeue using an array. ### Definitions: Let: * `deque[MAX]` be the array representing the dequeue. * `front` and `rear` be the integer variables indicating the two ends of the dequeue. * `MAX` be the maximum size of the dequeue. Initially, we set: * `front = -1` * `rear = -1` This indicates that the dequeue is empty. --- ### Algorithm to Insert Element at Front: Algorithm InsertFront(deque, front, rear, item) 1. If (front == 0 and rear == MAX - 1) or (front == rear + 1) * Output: "Overflow" * Exit 2. If (front == -1) // Dequeue is initially empty * Set front ← 0 * Set rear ← 0 3. Else if (front == 0) * Set front ← MAX - 1 4. Else * Set front ← front - 1 5. Set deque\[front] ← item 6. Exit --- ### Algorithm to Insert Element at Rear: Algorithm InsertRear(deque, front, rear, item)
____ ________ __________ ________ _______.___ ____ ____ ____ _____ ___ ______ ______ ________.
______ ____ ________ _________ _______ _______ ______ ____ ________ ______.
___ __________ ____ ____ ______ ___ ___ _______ _______ _______ ____.
___ _____ _______ _______ _________ __________ _______ ___ ____ ___.
___ __________ ______ __________ _____ __________ ____ _______ ______ ________.
_________ ___ _________ _________ _____ _______ __________ ___ ______.
______ _______ ________ __________ ______ ___ ___ __________.
_________ _____ _________ _________ ________.
____ _____ ________ ________ ___ _______ ___ _________ _________.
____ ______ ______ _________ ___.
_______ ___ ______ _________ _________ ________ ___ ________.
____ ____ ________ ___ ____.
___ _____ __________ ____ ___ _________ __________ ___ __________ ________ _________ ____.
_________ ___ __________ _________ ____ __________ ______.
________ ________ ____ _____ _____ _______ ______ _____ _____ _________.
_______ ________ _______ ___ ___ ________ ____.
_____ ___ ___ ____ ______.
_________ __________ _________ ______ _________ _________ _____ ____ ___.
_____ ___ ________ ________ _____ ________ ______ _________.
_______ _____ ________ ____ ________ ________ ____ ________ ___ _________.
__________ ____ ____ ___ ______ ______ ________ _______.
_______ ______ _______ _______ _______.
____ ___ ______ ____ ____ ___ ____ _____ ___ _________ _____.
__________ __________ ____ _____ ________ _____ ____.
_______ __________ _________ ____ ________ ______ ________ _____ ______.
________ _________ _________ _____ _______ _________ _______ _____ ____ ___ _______ ____.
__________ ______ ___ ___ _______ ___.
______ ______ ______ ___ _____ _____ _____ ____.
____ _______ ________ ____ __________ ______ _______ ____ __________.
______ __________ __________ ___ ________ ___ ________ ___ _________ ________ ______.
__________ ___ _______ __________ __________.
__________ ________ ______ __________ __________ ________.
_____ _______ ______ _________ ________ _______ ____ ____ _________.
_____ __________ _________ _____ ___ ________ ___ _______.
______ ____ ____ ______ _________ _____ __________ ___ _________ _________ ____.
_____ _____ ___ ____ ________ ___ ________ ______ ____.
_____ _____ ________ ________ ______ __________.
________ _____ _____ ________ ____ ______ ________ _______ _______.
__________ _____ _________ ________ _________.
_________ ____ ____ _____ ___ _______ ___.
__________ _____ ______ _____ ____.
________ ____ _________ ______ _________.
_______ _____ ___ ____ ____ _____ __________ __________ ______ ______ _____.
______ __________ __________ ____ _________ _________ __________ _________ __________ ___.
_____ ___ _____ ___ _____ __________ ______ ________ _____ ________.
____ ________ _________ ____ ________ ____ ___ _________ _______ ______ __________ ____.
__________ _______ _______ ______ ________.
______ ______ _________ __________ _________ ___.
______ _______ ________ _____ ______ ____ _____ _______ _____ ________ ___ __________.
__________ _____ _______ _______ ____ ___ __________.
_______ _________ ___ __________ __________ ________ _______ _________ __________ ______.
________ ___ ______ ______ _________.
___ ___ ___ ____ ___ __________.
_____ ______ _________ ___ ____ _______ ______ _____ _________ ________ ______.
_____ _________ ___ ____ ______ _______.
___ ________ _______ ____ ___ ____ _____ _______ __________ _____ _______ ____.
______ ______ __________ ______ ______ _______ ___ ___ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.