Question
Implement the Queue ADT using array based approach. Using C++ programming Language #include QueueArray.h template QueueArray ::QueueArray(int maxNumber) { } template QueueArray ::QueueArray(const QueueArray& other)
Implement the Queue ADT using array based approach. Using C++ programming Language
#include "QueueArray.h"
template
template
template
template
template
template
template
template
template
template
template
template
//--------------------------------------------------------------------
template
{ int j; // Loop counter
if ( front == -1 ) cout << "Empty queue" << endl; else { cout << "Front = " << front << " Back = " << back << endl; for ( j = 0 ; j < maxSize ; j++ ) cout << j << "\t"; cout << endl; if ( back >= front ) for ( j = 0 ; j < maxSize ; j++ ) if ( ( j >= front ) && ( j <= back ) ) cout << dataItems[j] << "\t"; else cout << " \t"; else for ( j = 0 ; j < maxSize ; j++ ) if ( ( j >= front ) || ( j <= back ) ) cout << dataItems[j] << "\t"; else cout << " \t"; cout << endl; } }
QueueArray.h
___-----------------------------------------------------------------------------
#ifndef QUEUEARRAY_H #define QUEUEARRAY_H
#include
using namespace std;
#include "Queue.h"
template
void enqueue(const DataType& newDataItem) throw (logic_error); DataType dequeue() throw (logic_error);
void clear();
bool isEmpty() const; bool isFull() const;
void putFront(const DataType& newDataItem) throw (logic_error); DataType getRear() throw (logic_error); int getLength() const;
void showStructure() const;
private: int maxSize; int front; int back; DataType* dataItems; };
#endif
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