Question: Consider the following Queue class that uses linked list to construct a Queue. class Node; typedef Node* NodePtr; class Node { public: int number; NodePtr
Consider the following Queue class that uses linked list to construct a Queue.
class Node; typedef Node* NodePtr;
class Node { public: int number; NodePtr next; Node(){number=0; next=NULL;} Node(int n){number=n; next=NULL;} }; //----------------------------------------
class Queue { private: NodePtr top; int currSize; const int fullSize;
public: //initalizez the Queue to an empty Queue (fixed size of 5) Queue() { fullSize= 5; currSize= 0; top= NULL; }
//initializes the Queue to an empty Queue and specific maximum size Queue(int maxSize) { fullSize= maxSize; currSize= 0; top = NULL; }
int enqueue(int item); //places an item into the Queue. Returns -1 if operation is not successful int dequeue(int& item); //removes an item from the Queue. Returns -1 if operation is not successsful bool empty(); //checks if the Queue is empty bool full(); //checks if the Queue is full };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
