Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Queue : Using an array to inset, delete, display and getfront. // C++ program to implement a queue using an array // Task 2

// Queue : Using an array to inset, delete, display and getfront.

// C++ program to implement a queue using an array

// Task 2 : Edit the statement in function main() to enqueue/insert more than 5 integer. // write the output of task 2. What are the reason of getting this output.?

// Task 3: edit this program so it can handle the problem of rightward drifting. // Show the implementation of queue circular array - follow the example in the slide in terms of array elements and size.

#include

using namespace std; int queue[5], n = 5, front = 0, rear = - 1;

void enqueue(int val) {

if (rear == n - 1) cout<<"Queue Overflow - Cannot add"<

// Driver code int main(void) {

// inserting elements in the queue, 40 30 20 50 enqueue(40); enqueue(30); enqueue(20); enqueue(50);

// print Queue elements display();

// insert element in the queue, 60 enqueue(60);

// print Queue elements 40 30 20 50 60 display();

dequeue(); //delete 40 dequeue(); //delete 30

cout<<" after two node deletion "<

// print Queue elements display(); // 20 50 60

// print front of the queue cout<<" Front element "<

return 0; }

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

Why is collaboration among universities important?

Answered: 1 week ago

Question

What are consolidated financial statements? LO1.

Answered: 1 week ago

Question

define the term outplacement

Answered: 1 week ago

Question

describe the services that an outplacement consultancy may provide.

Answered: 1 week ago