#include using namespace std; #define SIZE 5   //creating the queue using array int A[SIZE]; int front = -1; int rear = -1;   //function to check if the queue is empty bool isempty() { if(front == -1 && rear == -1) return true; else return false; }   //function to enter elements in queue void enqueue ( int value ) { //if queue is full if ((rear + 1)%SIZE == front)    cout<<"Queue is full \n"; else {  //now the first element is inserted  if( front == -1)     front = 0; //inserting element at rear end rear = (rear+1)%SIZE;   A[rear] = value; } }   //function to remove elements from queue void dequeue ( ) { if( isempty() )  cout<<"Queue is empty\n"; else //only one element if( front == rear )  front = rear = -1; else  front = ( front + 1)%SIZE; }   //function to show the element at front void showfront() { if( isempty()) cout<<"Queue is empty\n"; else cout<<"element at front is:"<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

#include <iostream>

using namespace std;

#define SIZE 5

 

//creating the queue using array

int A[SIZE];

int front = -1;

int rear = -1;

 

//function to check if the queue is empty

bool isempty() {

if(front == -1 && rear == -1)

return true;

else

return false;

}

 

//function to enter elements in queue

void enqueue ( int value ) {

//if queue is full

if ((rear + 1)%SIZE == front)

   cout<<"Queue is full \n";

else {

 //now the first element is inserted

 if( front == -1)

    front = 0;

//inserting element at rear end

rear = (rear+1)%SIZE;

  A[rear] = value;

}

}

 

//function to remove elements from queue

void dequeue ( ) {

if( isempty() )

 cout<<"Queue is empty\n";

else

//only one element

if( front == rear )

 front = rear = -1;

else

 front = ( front + 1)%SIZE;

}

 

//function to show the element at front

void showfront() {

if( isempty())

cout<<"Queue is empty\n";

else

cout<<"element at front is:"<<A[front];

}

 

//function to display the queue

void displayQueue() {

if(isempty())

 cout<<"Queue is empty\n";

else {

 int i;

 if( front <= rear ) {

  for( i=front ; i<= rear ; i++)

  cout<<A[i]<<" ";

 }

 else {

  i=front;

  while( i < SIZE) {

  cout<<A[i]<<" ";

  i++;

  }

  i=0;

  while( i <= rear)

  {

  cout<<A[i]<<" ";

  i++;

  }

 }

}

}

 

 

//function to check if Queue is empty

// emptyCheck(){

 

 

// }

 

 

//function to check if Queue is full

 

 

 

//function to purge the Queue

void purge_queue(){

   cout<<"Deleting the entire queue..."<<endl;

   delete[] isempty();

   exit(1);

}




This is a Queue Program using Circular Array. I would like to know how can I implement the rest of these functions :

 

  1. Function to check if the Queue is empty? 
  2. Function to check if the Queue is Full 
  3. Function to purge or Destroy the Queue

 



Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education