Question: Analysis of Algorithms (C++) Write a main.cpp and vector.cpp Header file: //-------------------------------------------------------------------- // // Homework Vector.h // // Class declaration for the array implementation of

 Analysis of Algorithms (C++) Write a main.cpp and vector.cpp Header file:

Analysis of Algorithms (C++) Write a main.cpp and vector.cpp

Header file:

//--------------------------------------------------------------------

//

// Homework Vector.h

//

// Class declaration for the array implementation of the Vector ADT

//

//--------------------------------------------------------------------

#ifndef VECTOR_H

#define VECTOR_H

using namespace std;

template

class Vector

{

public:

// 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(int item); // Remove the given element from the vector

void clear (); // Make the vector empty

// Vector status operations

bool isEmpty () const; // Is the Vector empty?

bool isFull() const; // Is the Vector full?

int contains(const int item) const; // 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; // Return the number of items in the vector

DataType &operator[] (const int index); // overloading subscript []

private:

// Data members

int capacity; // the capacity of the vector

int size; // Actual number of data item in the vector

DataType *dataItems; // Array containing the vector data item

};

#endif

Homework #1 (100 Points) 02/04/2019 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 clear0 Make the collection empty contains(element) - Does the collection contain the given element? elementAt(index) - Access the element at the given index isEmptyO - Is the collection empty? isFullO - Is the collection full? * * removeAt(index) - Remove the element at the given index * getSize0 - 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++ programminjg practice to name these files. Do NOT change any of their names or upload other files to ecourses

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!