Question
- Implement array based queue ( 50 pts ) - Implement linked-list based queue ( 50 pts ) In either of which, - enqueue(): (
- Implement array based queue (50 pts)
- Implement linked-list based queue (50 pts)
In either of which,
- enqueue(): (15 pts)
- dequeue(): (15 pts)
- Others (constructor, destructor, clear(), isEmpty(), isFull()):
(20 pts)
QueueLinked.h
// QueueLinked.h
#include
#include
using namespace std;
#include "Queue.h"
template
class QueueLinked : public Queue
public:
QueueLinked(int maxNumber = Queue
QueueLinked(const QueueLinked& other);
QueueLinked& operator=(const QueueLinked& other);
~QueueLinked();
void enqueue(const DataType& newDataItem) throw (logic_error);
DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const;
bool isFull() const;
// Programming Exercise 2
void putFront(const DataType& newDataItem) throw (logic_error);
DataType getRear() throw (logic_error);
// Programming Exercise 3
int getLength() const;
void showStructure() const;
private:
class QueueNode {
public:
QueueNode(const DataType& nodeData, QueueNode* nextPtr);
DataType dataItem;
QueueNode* next;
};
QueueNode* front;
QueueNode* back;
};
QueueLinked.cpp
#include "QueueLinked.h"
template
QueueLinked
{
}
template
QueueLinked
{
}
template
QueueLinked
{
}
template
QueueLinked
{
}
template
QueueLinked
{
}
template
void QueueLinked
{
}
template
DataType QueueLinked
{
DataType temp;
return temp;
}
template
void QueueLinked
{
}
template
bool QueueLinked
{
return false;
}
template
bool QueueLinked
{
return false;
}
template
void QueueLinked
{
}
template
DataType QueueLinked
{
DataType temp;
return temp;
}
template
int QueueLinked
{
}
template
void QueueLinked
{
QueueNode *p; // Iterates through the queue
if ( isEmpty() )
cout << "Empty queue" << endl;
else
{
cout << "Front\t";
for ( p = front ; p != 0 ; p = p->next )
{
if( p == front )
{
cout << '[' << p->dataItem << "] ";
}
else
{
cout << p->dataItem << " ";
}
}
cout << "\trear" << endl;
}
}
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