Update in Deque() fuction

Because of earlier logic not going to deque the last element of the queue because at the last front == rear as per your logic which directly results in "Underflow".
This commit is contained in:
Omkar Kolate
2019-08-15 16:10:59 +05:30
committed by GitHub
parent 71b03523dd
commit 3631f6570e

View File

@@ -35,7 +35,7 @@ void Enque(int x)
void Deque()
{
if (rear==front)
if (rear == NULL && front == NULL)
{
cout<<"\nUnderflow";
}
@@ -45,6 +45,8 @@ void Deque()
cout<<"\n"<<t->val<<" deleted";
front=front->next;
delete t;
if(front == NULL)
rear = NULL;
}
}