Related questions
Concept explainers
#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 :
- Function to check if the Queue is empty?
- Function to check if the Queue is Full
- Function to purge or Destroy the Queue
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- struct insert_at_back_of_sll { // Function takes a constant Book as a parameter, inserts that book at the // back of a singly linked list, and returns nothing. void operator()(const Book& book) { /// TO-DO (3) /// // Write the lines of code to insert "book" at the back of "my_sll". Since // the SLL has no size() function and no tail pointer, you must walk the // list looking for the last node. // // HINT: Do not attempt to insert after "my_sll.end()". // ///// END-T0-DO (3) ||||// } std::forward_list& my_sll; };arrow_forwardprogram Linked List: modify the following program to make a node containing data values of int, char, and string. #include <iostream> using namespace std; struct node { int data; struct Node *next; }; struct Node* head = nullptr;//or Null or 0; void insert(int new_data) { struct Node* new_node=(struct Node*) new(struct Node); new_mode->data=new_data; new_mode->next=head; head=new_node; } void display() { struct Node* ptr; ptr=head; while(ptr ! = NULL) { cout<<ptr->data<<""; ptr=ptr->next; } } int main() { insert{2}; display{}; return0; }arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education