mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-09 13:37:25 +08:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user