Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the ArrayQueue class in the class GitHub (https://github.com/apanangadan/CSUF-CPSC_131/blob/master/ArrayQueue.h) page to make the array queue capacity extendable. Assuming the default queue capacity is 5. You

Modify the ArrayQueue class in the class GitHub (https://github.com/apanangadan/CSUF-CPSC_131/blob/master/ArrayQueue.h) page to make the array queue capacity extendable.

Assuming the default queue capacity is 5.

You only need to write and show the C++ codes to implement the below two functions:

a. void resize(int N);

This function resizes the current queue array capacity to N.

b. void enqueue(const E& e);

This function appends a new element to the back of the queue. If the queue is full then it calls the resize function to double the current capacity and then en-queue the new element to the new capacity queue.

Example of an Extendable Array Queue Class declaration:

template

class ExtArrayQueue {

enum { DEF_CAPACITY = 5 }; // default queue capacity

public:

ExtArrayQueue(int cap = DEF_CAPACITY); // constructor from capacity

int size() const; // number of items in the queue

bool empty() const; // is the queue empty?

const E& front() const; // get the front element

void enqueue(const E& e); // add to back of queue

void dequeue(); // remove from front of queue

void printAll(); // print all elements in the queue

Private:

void resize(int N); // resize the array to size N

E* Q; // array of queue elements

int capacity; // queue capacity

int f; // index of the front of the queue

int r; // index of the rear of the queue

int n; // number of elements

};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

Students also viewed these Databases questions

Question

l Describe your current job using the job characteristics model.

Answered: 1 week ago

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

2. How will the team select a leader?

Answered: 1 week ago