Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C++ Standard Template Library (STL) Discussion (requirement for STL): 1. #include 2. Operations on queue q: a. q.empty() - test if queue is
Using C++ Standard Template Library (STL) Discussion (requirement for STL): 1. #include 2. Operations on queue q: a. q.empty() - test if queue is empty b. q.size()- how many items are queue c. q.push(t)-push t of type T onto the top of the queue d. q.pop()-pop the front item off the queue e. q.front()- get the front item from the queue f. q.back() - get the back item from the queue g. q.front() = expression - set/change the item at front h. q.back() expression - set/change the item at back = Copy and paste the following program in your IDE, inspect the output and do the exercise. #include #include using namespace std; int main() ( } queue q; q.push (1); q.push (2); q.push (3); q.push (4); cout < < "There are < Create a queue application with 1. an empty queue of integers 2. add numbers to the queue, 3. calculate and print the difference between the first and the last element. Example: Input: 2, 3, 4, 5, 6, 7, 8, 9 Output: 7 Explanation: Last element is 9, first element is 2, the difference is 7 Without using C++ queue STL, write a simple menu based selection to insert, delete, show and exit from queue. 1. Create a class called Queue with member variable queueArr as integer queue array, integer rear and integer front to keep track both rear and front element in the queue array. 2. Define several member functions in Queue such as a a. constructor-initialize both rear and front to -1 b. insert-receive an integer and check if queue is full, if not then insert the integer to the queue array c. delete - delete front element from queue if front is not equal to rear (empty) d. display - if rear is not equal to front, then print out the queue array. 3. Write a main function to test the Queue class. No. 1. 2. 3 Assessment Criteria Create a class called Queue with member variable queueArr, integer queue array, integer rear, integer front a. Initialize rear and front to -1 b. Receive an integer and check if queue is full, if not then insert the integer to the queue array c. Delete front element from queue if front is not equal to rear (empty) d. Print out the queue array if rear is not equal to front. a. Provides a choice to the user if they want to insert, delete or display the queue. b. According to the user response, the appropriate function is called.
Step by Step Solution
★★★★★
3.41 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
Exercise read the comments include 2 using na...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started