April 2018
Intermediate to advanced
322 pages
6h 57m
English
The implementation of the Front() and IsEmpty() operations for the Deque data type is the same as the implementation of the Front() and IsEmpty() operations for the Queue data type. For the Back() operation, it just returns the value of the m_back node. The implementation should be as follows:
template <typename T>T Deque<T>::Back(){ // Just return the value // of m_back node return m_back->Value;}
Since the implementation of this operation doesn't depend on the number of Deque elements, the complexity of this operation is O(1) for both best and worst case.