Question
Write only function. In c++

3. a) Write a function, to be included in a queue class - circular array implementation (20 p that will print all the items in the queue from front to rear
0 0
Add a comment Improve this question Transcribed image text
Answer #1

void display()
{
int i;
if(front==-1)
cout<<"Queue is empty";
else
{
if(front<=rear)
{
for(i=front;i<rear;i++)
cout<<arr[i]<<" ";
}
else //when rear is greater than front
{
for(i=front;i<size;++i)
cout<<arr[i]<<" ";
for(i=0;i<=rear;++i)
cout<<arr[i]<<" ";
}
}
}

Add a comment
Know the answer?
Add Answer to:
Write only function. In c++ 3. a) Write a function, to be included in a queue...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please write them in parts and not the whole code Page 3 of 5 based queue...

    please write them in parts and not the whole code Page 3 of 5 based queue - coding question rray-based fine an array-bag ray-based queue template class ArrQueue that uses a one-dimensional circular array esent the queue. The class consists of member variables: items, front, back, count. Wher functions: enqueue, dequeue, is Empty, peek Front. to represent the queue ement/ write code for enqueue member function ment/ write code for dequeue member function

  • 3. A queue implementation is being done using a circular array. It has a front and...

    3. A queue implementation is being done using a circular array. It has a front and a rear index for the array. Given that the queue length is q.length, give the following tests: How do you test if the queue is empty? How do you test if the queue is full? Assuming the queue is not empty, how do you remove an item from the queue? (How do you update the values for front and/or rear?) Assuming the queue is...

  • A deque (pronounced “deck”) is like a queue, except that items may be added and removed...

    A deque (pronounced “deck”) is like a queue, except that items may be added and removed from both the front and the rear. Write either an array-based or linked implementation for the deque. in C++ PLEASE SHOW A PIC OF THE OUTPUT

  • (C++) (VISUAL STUDIO) Circular Queue is a linear data structure in which the operations are performed...

    (C++) (VISUAL STUDIO) Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. In a normal Queue, we can insert elements until queue becomes full. But once queue becomes full, we cannot insert the next element even if there is a space in front of queue. Efficiently implement a queue class using a circular...

  • JAVA 1.         Implement an array-based queue that enqueus 3 items and prints them, dequeues one element...

    JAVA 1.         Implement an array-based queue that enqueus 3 items and prints them, dequeues one element and print it, and prints the front and rear items. Sample output: 1 enqueued 2 enqueued 3 enqueued 1 dequeued 2 is front item 3 is rear item

  • Q.1. Write a C program that determines whether a line entered by a user is a...

    Q.1. Write a C program that determines whether a line entered by a user is a palindrome or not. You must demonstrate it as an application of stack (you may use linked list implementation demonstrated in the class). Hint! Think of the basic property of a stack i.e. LIFO (list-in-first-out). Q.2. Write a charQueue header file containing all the function headers of following functions: 1- initiateQueue—to initialize a queue 2- enqueue—to add a node at the rear end of the...

  • Build and use your own minimal queue class using an array of type String of fixed...

    Build and use your own minimal queue class using an array of type String of fixed size to hold the queue. The array should have the default size of 5. The array size should be setable via a constructor. The following methods must be implemented: enqueue – inserts a value at the rear of the queue dequeue – returns the value at the front of the queue, removing the value from the queue isEmpty – returns true if the queue...

  • Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds value...

    Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds values of double data type. 1.) Create a program that produces the following output OUTPUT: Q Quit Enter your choice: e Enter an item: 1.1 E Enqueue D Dequeue s-show queue ← showMenuO function called in main) OQuit // screen clears-.. continue enqueuing.screen clearing with each iteration Enter your choice: e Queue is full. E Enqueue D Dequeue s Show queue 0...

  • PROBLEM- void CBQueue::printF2B( ) If the queue is empty, the method should print “Queue is empty”,...

    PROBLEM- void CBQueue::printF2B( ) If the queue is empty, the method should print “Queue is empty”, otherwise, this method should print the items in the queue starting at the front of the queue and proceeding to the rear of the queue. The items should be printed one per line. Now that this method is written, you can do a more thorough job of testing enqueue( ). You will want to call printF2B( ) and printB2F( ) after implementing each method...

  • Write a function that takes a string parameter and determines whether the string contains matching grouping...

    Write a function that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ) , brackets [] and curly braces { }. For example, the string {a(b+ac)d[xy]g} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac}d) do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string). Your function must use...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT