EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

In DEQUE, insertion and deletion operations are performed at both ends of the Queue.

Exceptional Condition of DEQUE

  • Input Restricted DEQUE

Here insertion is allowed at one end and deletion is allowed at both ends.

Deletion

Insertion

Front Rear

  • Output Restricted DEQUE

Here insertion is allowed at both ends and deletion is allowed at one end.

Insertion              Deletion

Front                                   Rear

Operations on DEQUE

Four cases for inserting and deleting the elements in DEQUE are

  1. Insertion At Rear End [ same as Linear Queue
  2. Insertion At Front End
  3. Deletion At Front End [ same as Linear Queue ]
  4. Deletion At Rear End

Case 1: Routine to insert an element at Rear end

void Insert_Rear (int X, DEQUE DQ)

{

if( Rear = = Arraysize – 1)

Error(“Full Queue!!!! Insertion not possible”); else if( Rear = = -1)

{

Front = Front + 1; Rear = Rear + 1; DQ[ Rear ] = X;

}

else

{

Rear = Rear + 1; DQ[ Rear ] = X;

}

}

Case 2: Routine to insert an element at Front end

void Insert_Front ( int X, DEQUE DQ )

{

if( Front = = 0 )

Error(“Element present in Front!!!!! Insertion not possible”); else if(Front = = -1)

{

Front = Front + 1; Rear = Rear + 1; DQ[Front] = X;

}

else

{

Front = Front – 1; DQ[Front] = X;

}

}

Case 3: Routine to delete an element from Front end

void Delete_Front(DEQUE DQ)

{

if(Front = = – 1)

Error(“Empty queue!!!! Deletion not possible”); else if( Front = = Rear )

{

X = DQ[ Front]; Front = – 1; Rear = – 1;

}

else

{

X = DQ [ Front ]; Front = Front + 1;

}

}

Case 4: Routine to delete an element from Rear end

void Delete_Rear(DEQUE DQ)

{

if( Rear = = – 1)

Error(“Empty queue!!!! Deletion not possible”); else if( Front = = Rear )

{

X = DQ[ Rear ];

Front = – 1; Rear = – 1;

}

else

{

X = DQ[ Rear ];

Rear = Rear – 1;

}

}

DOUBLE-ENDED QUEUE (DEQUE) IN DATASTRUCTURES

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer