Toy Version of A Deque Programming Worksheet
Description
Implement a toy version of a deque using two std::vector
s.
The type of element the deque holds can be passed as a template
parameter and we will test your solution instantiating the template type
with int
, double
, char
, and std::string
. You are not allowed to use std::deque
itself in this exercise. There are 5 groups of member functions that
you need to implement for this assignment, which we now describe.
Constructors:
NOTE: ALL PICTURES ARE IN THE “PICTURES” ZIP FILE
You will implement 3 constructors:
SEE PICTURE 1
Front and Back
Member functions to get the first and last element of the deque. These functions should work in constant time.
SEE PICTURE 2
Operator[]
Access an element of the deque by its index. This function should work in constant time.
SEE PICTURE 3
Push/Pop Back/Front
Add/Remove an element from the front or back of the deque. These functions should work in constant amortised time.
SEE PICTURE 4
Functions Related to the Number of Elements
Two functions related to the number of elements in the MyDeque. These should work in constant time.
SEE PICTURE 5
The Code
There are three files provided in the scaffold.THESE ARE INCLUDED IN THE “IMPLEMENT A DEQUE” ZIP FILE
- The
header file myDeque.hpp contains the definitions of all member
functions of the MyDeque class. We provide a scaffold here, but you are
free to add member variables and helper member functions as needed. - The implementation file myDeque.cpp. This is where you should implement all the required member functions.
- As
usual we provide a file main.cpp for your own testing and debugging
purposes. This is the file that is compiled and executed when “Run” is
pressed. You can modify this file as you like. The marker does not
make use of this file.

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."