Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

implement the QueueLinked using the linked list approach. Use C++ programming la

ID: 3806252 • Letter: I

Question

implement the QueueLinked using the linked list approach. Use C++ programming language

#include "QueueLinked.h"

template <typename DataType>
QueueLinked<DataType>::QueueNode::QueueNode(const DataType& nodeData, QueueNode* nextPtr)
{
}

template <typename DataType>
QueueLinked<DataType>::QueueLinked(int maxNumber = Queue<DataType>::MAX_QUEUE_SIZE)
{
}

template <typename DataType>
QueueLinked<DataType>::QueueLinked(const QueueLinked& other)
{
}

template <typename DataType>
QueueLinked<DataType>& QueueLinked<DataType>::operator=(const QueueLinked& other)
{
}

template <typename DataType>
QueueLinked<DataType>::~QueueLinked()
{
}

template <typename DataType>
void QueueLinked<DataType>::enqueue(const DataType& newDataItem) throw (logic_error)
{
}

template <typename DataType>
DataType QueueLinked<DataType>::dequeue() throw (logic_error)
{
   DataType temp;
   return temp;
}

template <typename DataType>
void QueueLinked<DataType>::clear()
{
}

template <typename DataType>
bool QueueLinked<DataType>::isEmpty() const
{
   return false;
}

template <typename DataType>
bool QueueLinked<DataType>::isFull() const
{
   return false;
}

template <typename DataType>
void QueueLinked<DataType>::putFront(const DataType& newDataItem) throw (logic_error)
{
}

template <typename DataType>
DataType QueueLinked<DataType>::getRear() throw (logic_error)
{
   DataType temp;
   return temp;
}

template <typename DataType>
int QueueLinked<DataType>::getLength() const
{
}

template <typename DataType>
void QueueLinked<DataType>::showStructure() const
{
QueueNode *p; // Iterates through the queue

if ( isEmpty() )
   cout << "Empty queue" << endl;
else
{
   cout << "Front ";
   for ( p = front ; p != 0 ; p = p->next )
   {
   if( p == front )
   {
       cout << '[' << p->dataItem << "] ";
   }
   else
   {
       cout << p->dataItem << " ";
   }
   }
   cout << " rear" << endl;
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

QueueLinked.h

#include <stdexcept>
#include <iostream>

using namespace std;

#include "Queue.h"

template <typename DataType>
class QueueLinked : public Queue<DataType> {
public:
QueueLinked(int maxNumber = Queue<DataType>::MAX_QUEUE_SIZE);
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;
};

Explanation / Answer

QueueLinked.cpp