Answer:
Check the explanation
Step-by-step explanation:
Abstract Data type (ADT) can be refereed to as a class for objects whose behavior is influenced inline with a set of value and a set of operations.
#include<iostream>
const int MAX=20;
class dque
{
private:
int arr[MAX];
int front,rear;
public:
dque();
void addqatbeg(char item);
void addqatend(char item);
int delqatbeg();
int delqatend();
void display();
int count();
};
dque::dque()
{
front=rear=-1;
for(int i=0;i<MAX;i++)
arr[i]=0;
}
void dque::addqatbeg(int item)
{
if(front==0&&rear==MAX-1){cout<<"\\Deque is full"<<endl;return;}
if(front==-1){front=rear=0;arr[front]=item;return;}
if(rear!=MAX-1)
{int c=count();int k=rear+1;
for(int i=1;i<=c;i++){arr[k]==arr[k-1];k--;}
arr[k]=item;front=k;rear++;
}
else{front--;arr[front]=item;}
}
void dque::addqatend(int item)
{
if(front==0&&rear==MAX-1){cout<<"\\Deque is full"<<endl;return;}
if(front==-1){front=rear=0;arr[rear]=item;return;}
if(rear==MAX-1){
int k=front-1;
for(int i=front-1;i<rear;i++){k=i;
if(k==MAX-1)arr[k]=0;
else arr[k]=arr[i+1];
}rear++;
arr[rear]=item;
}
int dque::delqatbeg()
{
if(front==-1){cout<<"\\Deque is empty"<<endl;return0;}
int item=arr[front];
arr[front]=0;
if(front==rear)front=rear=-1;
else
front++;
return item;
}
int dque::delqatend()
{
if(front==-1){cout<<"\\Deque is empty"<<endl;return 0;}
int item=arr[rear];
arr[rear]=0;
rear--;
if(rear==-1)front=-1;return item;
}
void dque::display()
{
cout<<endl<<"front->";
for(int i=0;i<MAX;i++)cout<<""<<arr[i];cout<<"<-rear";
}
int dque::count()
{
int c=0;
for (int i=0;i<MAX;i++){if(arr[i]!=0)c++;}
return c;}
}