COMP 3053: Analysis of Algorithms (Spring 2019) Homework #1 (100 Points) 01/31/2020 Vector is an ordered set of elements that is also called dynamic array. It is similar to the list data structure that you learned in the data structure course, except that the data is saved in order (not sorted). You need to implement the Vector ADT using C++ class (prototype is provided by the instructor). You need to download the Vector.h file from the ecourses, and implement all functions defined in the class using C++ with a file named Vector.cpp. You will also need to create a Main.cpp to create object(s) of the Vector class, and test if these functions are working correctly. The following is the list of functions defined in Vector ADT. append(element) - Add a new element to the end of the collection. clear() - Make the collection empty. contains(element) - Does the collection contain the given element? elementAt(index) - Access the element at the given index. isEmpty - Is the collection empty? isFull - Is the collection full? removeAt(index) - Remove the element at the given index. getSize() - How many elements are in the collection? operator) - overload operator] to access an individual element in the vector insertAt(index, element) - Insert a new element at the given index. remove(element) - Remove the given element from the collection. Submission policy: You need to submit your completed program source code to ecourses by at the end of the class time. You need to upload all of your source code: Main.cpp, Vector.cpp, and Vector.h. You need to follow the C++ programming practice to name these files. Do NOT change any of their names or upload other files to ecourses. Please note that failure to follow the submission rule will NOT receive credit for the exam. // 11 Homework Vector.h 1 // Class declaration for the array implementation of the Vector ADT //- - #ifndef VECTOR #define VECTOR using namespace std; template
class Vector public: 1/ Constructors Vector(); // Default constructor // Destructor -Vector (; // Vector manipulation operations void append (const DataType item); // Add a new item to the end of the vector void insertat (const int index, const DataType item); // Insert a new element at the given index void removeAt (const int index); // Remove the data item at the given index void remove (DataType item); // Remove the given element from the vector void clear ; Make the vector empty 1/ Vector status operations bool isEmpty() const; Is the Vector empty? bool is Pullo) const; Is the Vector full? int contains (const Datatype item) const; 1/ Does the vector contain the given item? return the index of the item if found, otherwise, return -1. DataType elementat (const int index) const; / Access the element at the given index int getSize() const; 1/ Return the number of items in the vector DataType Soperator] (const int index); 11 overloading subscript O private: 1/ Data members int capacity: 11 the capacity of the vector int size; 11 Actual number of data item in the vector DataType dataItems; 11 Array containing the vector data item #endit