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...
-
You build a beat engine that takes 1.00 mol of an ideal diatomic gas through the cycle shown in Fig. 20.25. (a) Show that segment ab is an isothermal compression. (b) During which segment(s) of the...
-
How would you demonstrate the influence of relevant theory in your research proposal?
-
What is the definition of ignorable treatment assignment? a. Give an example of a study where the treatment assignment is ignorable. b. Give an example of a study where the treatment assignment is...
-
AIG, which received more than $170,000,000 in taxpayer bailout money from the U.S. Treasury, planned to pay $165,000,000 in bonuses to its executives in 2009. Requirement 1. Suppose you were one of...
-
The Little Rock Planning Board of Adjustments meets regularly and submits their recommendations for zoning changes to the City Board of Directors. The Board of Directors typically meets twice...
-
D. Deni commenced business on 1 April 2014 by depositing Sh.8 million into the business bank account. All receipts and payments were channelled through this business account. During the year ended 31...
-
How do advance agreements add to worldwide monetary administration on the off chance that reviews, and what advantages and impediments do they propose for overseeing money risk in worldwide business...
-
1. A hungry virtual student named Pai buys a pie from the market and eats 4 slices. The slices subtend a combined angle of 3 4 . If each slice has a radius of 20 cm, what is the area of pie that Pai...
-
Determine the values of a where the function f (x) is not continuous. Label each discontinuity as removable, jump or infinite. X = x = Enter your answers as integers in increasing order. If there are...
-
A driverless pod is travelling between two stations. The velocity of the pod as it leaves station 1 is measured in metres per second and is shown in the graph below for an interval of 20 minutes....
-
Show your work completely Submit your answer on Canvas as one file in pdf by 1/16/2023 1. Find the area between the curve y=x* and x = y. 2. Find the volume of the solid generated by revolving the...
-
Consider the function. f(x) = x + 3 Calculate the right-endpoint approximation R5 for f on the interval [3, 4]. Round to two decimal places. R5
-
Calculate the total pressure (p SO 3 +p SO2 + p O2 ) exerted by equilibriated CoO andCoSO 4 at 1223 K. The answer listed in the back of the book: P = 1 atm (p SO3 = 7.99 x 10 -2 atm,p SO2 = 0.612...
-
A manufacturer can sell product 1 at a profit of $20 per unit and product 2 at a profit of $40 per unit. Three units of raw material are needed to manufacture one unit of product 1, and six units of...
-
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...
-
You are to open the books of F. Polk, a trader, via the journal to record the assets and liabilities, and are then to record the dialy transactions for the month of May. A trial balance is to be...
-
Show the journal entries necessary to record the following items: 2017 Apr 1 Bought office furniture on credit from Durham Brothers Ltd 1,400. 4 We take goods costing 270 out of the business...
-
You are to show the journal entries necessary to record the following items which occured in 2016: (a) May 1 Bought a motor bike on credit from Lakeside Garage for 5,500. (b) May 3 A debt of 347...
Study smarter with the SolutionInn App