Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Below are the Node and Stack classes ( Node.h and Stack.h ). Node.h: #ifndef NODEB_NODE_H #define NODEB_NODE_H /** Represents one node to be used in
Below are the Node and Stack classes (Node.h and Stack.h).
Node.h:
#ifndef NODEB_NODE_H #define NODEB_NODE_H /** Represents one node to be used in a linked list Contains data (object) and reference to next in list */ templatetypename Object> class Node { private: Object item; Node* next; public: Node(Object newItem) { item = newItem; next = nullptr; } Node(Object newItem, Node* nextNode) { item = newItem; next = nextNode; } void setItem(Object newItem) { item = newItem; } Object getItem() const { return item; } void setNext(Node* nextNode) { next = nextNode; } Node* getNext() const { return next; } }; #endif //NODEB_NODE_H
Stack.h:
#ifndef NODEB_STACK_H #define NODEB_STACK_H /* * Stack class * Each Node point to the Node below it * Functionality: push, pop, peek, isEmpty, print */ #include "Node.h" #includeusing namespace std; templatetypename Object> class Stack { private: // Store the address of the top Node in the Stack Node
Stack Class Start with the Stack class from lecture. What is the Big-Oh complexity of the methods? Queue Class Create a Queue class that uses the Node class from lecture to create a functioning queue data structure. . Your Queue should be able to push and pop Objects and determine if an Object is in the Queue. What is the complexity of each method? . Your Queue must be able to be used with any data type. Your Nodes must be stored in heap memory. . Your program must not have any memory leaks
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