Question: Valid Queue You are given a queue of integers. Check if the queue is valid. A valid queue is one in which the numbers are

Valid Queue

You are given a queue of integers. Check if the queue is valid. A valid queue is one in which the numbers are inserted in ascending order.

?The queue (5, 44, 333) is a valid queue while the queue (5,44,33) is not.

Input and Output:

The function should take a queue of integers as input and return true or false as output. If the queue is empty return true.

Note: You are given the STL Functions and you are free to use them:

Queue

??empty() Returns whether the queue is empty ??size() Returns the size of the queue ??push(g) Adds the element g at the end of the queue ??pop() Deletes the first element of the queue

??front() Returns a reference to the first element of the queue

??back() Returns a reference to the last element of the queue

Sample Input 1:

4 44 333

Sample Output 1:

true

Sample Input 2:

4 44 33

Sample Output 2:

false

Sample Input 3:

-5 6 11

Sample Output 3:

true

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!