Deque
Double Ended Queue 90% of vector operation we can do here . Here we can do 2 to 3 more operation . int n ; cin >> n ; deque dq(n) ; for(int i = 0 ;i > x ; //dq.push_back(x) ; cin >> dq[i] ; } dq.push_front(8) ; dq.push_front(2) ; for(auto value : dq) { cout

Double Ended Queue
90% of vector operation we can do here . Here we can do 2 to 3 more operation .
int n ;
cin >> n ;
deque dq(n) ;
for(int i = 0 ;i <= n ; i++){
//int x ;
//cin >> x ;
//dq.push_back(x) ;
cin >> dq[i] ;
}
dq.push_front(8) ;
dq.push_front(2) ;
for(auto value : dq)
{
cout << value << " " ;
}
cout << '\n' ;
sort(dq.begin(),dq.end()) ;
dq.pop_front() ;
for(auto value: dq)
{
cout << value << " " ;
}
cout << '\n' ;
}
}
Almost like a vector . Right?
In vector we can not insert at front in 0(1) . We can not delete at front in 0(1) .
Also can access the front value .
Last Element :
push_back()
pop_back()
back()->Access ;
First Element:
push_front()
pop_front()
front()
Drawback:
Here extra memory is used . When the dataset is very very big it is not efficient .Because here double pointer is used .