Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you were given the source code for building a queue data structure based on an array. You are given this source code ( assign 4

you were given the source code for building a queue data structure based on an array. You
are given this source code (assign4_part1.cpp) but it misses the implementation of the oddCheck
function. You are asked to provide the implementation of this function as described below.
The oddCheck inspects all values in the queues and prints only the odd values. #include
using namespace std;
const int MAXSIZE =100;
int queue[MAXSIZE];
int front =-1, rear =-1;
bool queueIsEmpty()
{
if(front <0)
return true;
else
return false;
}
bool queueIsFull()
{
if((rear+1)%MAXSIZE == front )
return true;
else
return false;
}
int peek()
{
return queue[front];
}
void enqueue(int data){
if(!queueIsFull()){
if(front ==-1)
{
front =0;
rear =0;
}
else
rear =(rear +1)%MAXSIZE;
queue[rear]= data;
}
else
cout << "Queue is full" << endl;
}
int dequeue()
{
int data = queue[front];
if(front == rear)
{
rear =-1;
front =-1;
}
else
front =(front +1)%MAXSIZE;
return data;
}
void printQueue(){
if(!queueIsEmpty()){
int i =0;
for(i = front; i != rear; )
{
cout<

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_2

Step: 3

blur-text-image_3

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Why are denormalized tables used in data warehouses?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago