Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***** WRITTEN IN C++******* I need an array queue implementation written. I've worked on this for hours and for whatever reason I can't figure it

***** WRITTEN IN C++*******

I need an array queue implementation written. I've worked on this for hours and for whatever reason I can't figure it out so I'm caving in.

It needs a header file called queue.h that has all of the prototypes needed (will list them and what they should do below). I need a cpp file created named queue.cpp and it needs to implement all of the functions I list. The queue uses an array of size 10, which needs to be static (outside files shouldn't have global access to it). The queue cannot have duplicate numbers, and this program SHOULD NOT crash.

The methods to be implemented are as followed:

int Enqueue(int num)

This adds whatever num is to the queue. Returns a 0 if it is successful, a -58 if the queue is full, and a -64 if the queue already contains num.

int Dequeue (int& num)

This removes whatever is at the front of the queue and puts it into num. It should return a 0 upon success or a -62 if the queue is empty.

int isEmpty()

This should return a 1 if the queue is empty and a 0 if it isnt.

int Exists (int num)

This should return a 1 if the num specified is in the queue. Returns a 0 if it doesn't exist.

void Clear(void)

This should simply removes all of the items within the queue.

void Print(void)

This should print all of the items in the queue on one line, with a space between each item. once its at the end, a linebreak should be printed.

int Duplicate(void)

this should make a copy of the first item in the queue and insert it into the front of the queue. This should return 0 upon success, -69 if the queue is empty, or a -99 if the operation would cause an overflow.

int Mul(void)

this should multiply the first two items within the queue and insert the product of those two items into the front of the queue. It should return a 0 if it is successful, -87 if there are not at least two items in the queue, or -82 if the result of mul would cause a duplicate.

int Reverse(void)

this should basically reverse all the items in the queue. The first item becomes the last and so on. this should return a 0 if it is successful.

int Peek(int& num)

this should get the first item and place it in num without removing it from the queue. This should return a 0 if it is successful, or a -71 if it fails.

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

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions