Question
For each method in the ArrayList class template, determine the asymptotic analysis. Use the length of the list as the input size . Create a
For each method in the ArrayList class template, determine the asymptotic analysis. Use the length of the list as the input size .
Create a main.cpp file that tests each method of the ArrayList. Also create scenarios that cause the different error messages to appear.
- List.hpp
- ArrayList.hpp
- main.cpp
#ifndef ARRAY_LIST_HPP #define ARRAY_LIST_HPP
#include "List.hpp" #include
// for all analyses // input size n is the length of the list
template
// the maximum number of elements in the list int maxSize;
public: // constructor with the maximum size as the argument ArrayList(int = 100);
// copy constructor ArrayList(const ArrayList
// overloaded assignment operator ArrayList
// destructor virtual ~ArrayList();
// add the argument to the end of the list virtual void append(const T&) override;
// remove all elements in the list virtual void clear() override;
// return the element at the given position (argument) virtual T getElement(int) const override;
// return the current length of the list virtual int getLength() const override;
// return the maximum size of the list int getMaxSize() const;
// insert the given element (argument 2) at // the given position (argument 1) virtual void insert(int, const T&) override;
// determine if the list currently empty virtual bool isEmpty() const override;
// determine if the list currently full bool isFull() const;
// remove the element at the given position (argument) virtual void remove(int) override;
// replace the element at the given position (argument 1) with // the value given (argument 2) virtual void replace(int, const T&) override;
// overloaded stream insertion operator template
// analyzing number of assignments // T(n) = ? template
// analyzing number of assignments // T(n) = ? template
for (int i = 0; i length; i++) { buffer[i] = copyObj.buffer[i]; } }
// analyzing number of assignments // T(n) = ? template
this->length = rightObj.length; maxSize = rightObj.maxSize; buffer = new T[maxSize];
for (int i = 0; i length; i++) { buffer[i] = rightObj.buffer[i]; }
return *this; }
// analyzing number of deletes // T(n) = ? template
// analyzing number of assignments // T(n) = ? template
// analyzing number of assignments // T(n) = ? template
// analyzing number of accesses // T(n) = ? template
// analyzing number of accesses // T(n) = ? template
// analyzing number of accesses // T(n) = ? template
// analyzing number of assignments // T(n) = ? template
// analyzing number of comparisons // T(n) = ? template
// analyzing number of comparisons // T(n) = ? template
// analyzing number of assignments // T(n) = ? template
// analyzing number of assignments // T(n) = ? template // analyzing number of output operations // T(n) = ? template return outStream; } #endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started