Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COMP 3053: Analysis of Algorithms (Spring 2021)Homework #1 (100 Points)Due Date: 02/08/2021Vector is an ordered set of elements that is also called dynamic array. It

COMP 3053: Analysis of Algorithms (Spring 2021)Homework #1 (100 Points)Due Date: 02/08/2021Vector 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 a C++ class (the header Bile is provided by the instructor). You need to download the Vector.h Bile from the ecourses, and implement all functions deBined in the class using C++ with a Bile 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 deBined 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 vectorinsertAt(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 Biles. Do NOT change any of their names or upload other Biles to ecourses.

/--------------------------------------------------------------------//// Homework Vector.h//// Class declaration for the array implementation of the Vector ADT////--------------------------------------------------------------------#ifndef VECTOR_H#define VECTOR_Husing 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 elementat 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 // Vector status operations bool isEmpty () const; // Is the Vector empty? bool isFull() const; // Is the Vector full? int contains(const DataType 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 givenindex int getSize() const; // Return the number of items in thevector DataType &operator[] (const int index); // overloading subscript [] private: // Data members int capacity; // the capacity of the vector int size; //

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions