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 but it misses

you were given the source code for building a queue data structure based on an array. You
are given this source code 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

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

More Books

Students also viewed these Databases questions

Question

For a six-level system, what are its levels of abstraction?

Answered: 1 week ago