0% found this document useful (0 votes)
10 views1 page

Understanding Queues and Deques in Algorithms

Uploaded by

mdfaisal10124
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Understanding Queues and Deques in Algorithms

Uploaded by

mdfaisal10124
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter 4 – Queue

1. Algorithm to Check Whether a String is Palindrome or Not.


>>Algorithm:
1. Initialize two pointers: start = 0, end = length-1.
2. While start < end:
If string[start] != string[end] → Not palindrome.
Increment start, decrement end.
3. If loop finishes → Palindrome.
2. What is Queue? Define Queue
A queue is a linear data structure that follows the FIFO (First In,
First Out) principle.
Insertion → Enqueue (rear end)
Deletion → Dequeue (front end)

3. What is Deque? Define Deque


>>A Deque (Double-Ended Queue) is a linear data structure that
allows insertion and deletion at both front and rear ends.

4. Difference Between Queue and Deque

Queue Deque
Insertion only at rear Insertion at both ends
Deletion only at front Deletion at both ends
Simpler structure More flexible structure

5. Difference Between Stack and Queue

Stack Queue
LIFO principle FIFO principle
Push & Pop Enqueue & Dequeue
One end used for both insertion and deletion Two ends: front
(delete) & rear (insert)
Example: Plates stack Example: Waiting line.

You might also like