Can you please help to analyze this algorithm?
Posted: Mon Jun 06, 2022 4:31 pm
Can you please help to analyze this algorithm?
. [15 points] We would like to implement a Stack data type, which is a container for a collection of items, similar to a list, where the items are retrieved based on the order they were added to the stack (we will discuss this data type later, but for now just realize that this means when we insert/delete items we do not need a position for the item). To implement our Stack data type we will implement a Stack class in C++ using the below class definition: template <class T> class Stack{ public: Stack(); Stack (const int& capacity); bool isEmpty() const; void push(const T& item); /* add an item to the stack */ T pop(); /* removes an item (and returns that item) from the stack */ void display (ostream& out) const; private: T* stackItems; int _size; int capacity; }; What additional member functions must be defined by this class (for full credit give the full function signature)? For each function, what problem(s) can occur if the function is not included (for full credit you must fully describe, in detail, what the problem is and how is occurs)?
. [15 points] We would like to implement a Stack data type, which is a container for a collection of items, similar to a list, where the items are retrieved based on the order they were added to the stack (we will discuss this data type later, but for now just realize that this means when we insert/delete items we do not need a position for the item). To implement our Stack data type we will implement a Stack class in C++ using the below class definition: template <class T> class Stack{ public: Stack(); Stack (const int& capacity); bool isEmpty() const; void push(const T& item); /* add an item to the stack */ T pop(); /* removes an item (and returns that item) from the stack */ void display (ostream& out) const; private: T* stackItems; int _size; int capacity; }; What additional member functions must be defined by this class (for full credit give the full function signature)? For each function, what problem(s) can occur if the function is not included (for full credit you must fully describe, in detail, what the problem is and how is occurs)?