Site icon Doc Sity

Toy Version of A Deque Programming Worksheet

Toy Version of A Deque Programming Worksheet

Description

Implement a toy version of a deque using two std::vectors.
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

  1. 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.
  2. The implementation file myDeque.cpp. This is where you should implement all the required member functions.
  3. 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.
Explanation & Answer:
Worksheet
User generated content is uploaded by users for the purposes of learning and should be used following our’s honor code & terms of service.

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

Exit mobile version