Using C++ Standard Template Library (STL) Discussion (requirement for STL): 1. #include 2. Operations on queue...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using C++ Standard Template Library (STL) Discussion (requirement for STL): 1. #include <queue> 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 <iostream> #include <queue> using namespace std; int main() ( } queue<int> q; q.push (1); q.push (2); q.push (3); q.push (4); cout << "There are <<q.size (); cout << " objects in the queue." << endl; cout << "The front item << q. front () << endl; cout << "The back item << q.back () << endl<< endl; "1 while (!q.empty()) { } 11 cout << "Time to serve the queue. Calling front: "; cout << q. front () << endl << endl; 11 cout << "Popping: " << q. front (); q.pop(); if (!q.empty()) cout << " Front: cout<< "\nQueue finished." << endl; cout << endl; return 0; << q. front () << endl; 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. Using C++ Standard Template Library (STL) Discussion (requirement for STL): 1. #include <queue> 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 <iostream> #include <queue> using namespace std; int main() ( } queue<int> q; q.push (1); q.push (2); q.push (3); q.push (4); cout << "There are <<q.size (); cout << " objects in the queue." << endl; cout << "The front item << q. front () << endl; cout << "The back item << q.back () << endl<< endl; "1 while (!q.empty()) { } 11 cout << "Time to serve the queue. Calling front: "; cout << q. front () << endl << endl; 11 cout << "Popping: " << q. front (); q.pop(); if (!q.empty()) cout << " Front: cout<< "\nQueue finished." << endl; cout << endl; return 0; << q. front () << endl; 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.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
From the long 19th century to the short 20th century (i) Explains the relevance of extractive and metallurgical activities for the promotion of international industrial development at the end of the...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
1. About 99 percent of the world's population lives outside Canada, but many Canadian companies, especially small businesses, still do not engage in global trade. Why not? Do you think more small...
-
Fill out the following table for substance water
-
Identify which of the following transactions would be classified as a current liability and which would be classified as a non-current liability. For those that are neither, identify where they...
-
What is the main regulatory condition of Basel I? What are the standard criticisms of Basel I?
-
The 3M Company is a global diversified technology company active in the following product markets: consumer and office; display and graphics; electronics and communications; health care; industrial;...
-
LG just paid a $2 annual dividend on its common stock. The dividend is expected to increase 5.5% per year indefinitely. If the required rate of return is 7.8%, What is the the stock's value next year?
-
Funtime, Inc., manufactures video game machines. Market saturation and technological innovations caused pricing pressures that resulted in declining profits. To stem the slide in profits until new...
-
What is File System? b. What is Database System? c. what are Five Major Parts of Database System d. What is Database? e. write down the Advantages and Disadvantages of Database System
-
wo firms share a market. If neither firm advertises, each firm makes $ 5 5 million. If a firm chooses to advertise, it will capture $ 3 3 million from its competitor provided that the competitor does...
-
Modify the following for loop into a while loop. int t=0; for (int i=1; i
-
A grinding mill in the Free State Province breaks down on average 5 times a month. What is the probability that the mill will not break down in a month?
-
Find r(t) if r' (t) = (6t (1-3),te,4 sin (1-2)) and r(2)=(2,-3,1) Suppose an object moves in space such that it position at time t hours is given by r(t) = (6t+1)i+t'j-ek. Find the velocity and...
-
ue 3 Fowing accounting ratios have been calculated for three firms Ras/ firms Y Cent Ratio 3:1 2:1 cid Test Ratio Debt Service Coverage Ratio Inventory Turnover Debtors' Turnover Creditor's Turnover...
-
After graduating from college, Melissa Malone landed a position with Orchard Creek, one of the finest children's boutiques in the Boston area. Three years ago, Melissa was promoted to Assistant...
-
Consider model (9.18). What is the effect on the model parameter estimates, their standard errors, and the goodness-of-fit statistics when (a) The times at risk are doubled, but the numbers of deaths...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-6. On December 12, Irene purchased the building where her store is located. She paid...
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
Kent Pham, CPA, is a 45-year-old single taxpayer living at 169 Trendie Street, La Jolla, CA 92037. His Social Security number is 865-68-9635. In 2012, Kent's W-2 as the controller of a local...
-
Examine resource rental pattern on following characteristics: a. Simplicity b. Generality c. Reusability d. Completeness e. Stability f. Visual and graphical model g. Testability
-
Draw a stable class diagram for account pattern.
-
What are the advantages of separating account and entry patterns?
Study smarter with the SolutionInn App