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 are currently working for Clissold Industries. The company, which went public five years ago, engages in the design, production, and distribution of lighting equipment and specialty products...
-
What impact do ratings have on a borrowers cost of debt?
-
The following information is available for Rapper Inc. - Taxable income in 2020: \(\$ 115,000\) - Accounts receivable on installment sales GAAP basis: \(\$ 150,000\) Tax basis: \(\$ 0\) - Tax rate:...
-
1. Trace the path of the medication list and denote possible failure points. Construct a process flowchart of the existing process and create a new chart of an improved process. 2. Was the medication...
-
Steinberg Company had the following direct materials costs forthe manufacturing of product T in March:Actual purchase price per pound of direct materials$ 8.80Standard direct materials allow 2 answers
-
The proposed rates were not in the range the CEO expected given the pricing analysis. The CEO has asked the pricing actuary to verify the total projected loss cost excluding potential large storm...
-
Example 5:- A waxed paper (F) containing 25 wt. % wax and 75 wt. % paper pulp are continuously fed at a rate of 1000 Ib/hr to a certain extraction unit in which 98% of the wax input to the unit to...
-
Sierra Corporation guarantees its snowmobiles for three years. Company experience indicates that warranty costs will add up to \(5 \%\) of sales. Assume that the Sierra dealer in Colorado Springs...
-
(a) Explain why quality control may be difficult to implement in a smaller audit firm and illustrate how such difficulties may be overcome. (b) Kite Associates is an association of small accounting...
-
Toker & have used me a State Masiname or ended 3 December 2010 They asked one of the audit staff to draft the audit report and he produced this: A roost semnation on a teer be to the amount and does...
-
Your firm is the external auditor of Octavia Ltd (Octavia). The team conducting the audit for the year ended 31 December 2X10 has recently returned to the office following completion of the audit...
-
Angela Goodbody is a partner in Tickitt & Run and has come to the audit of E-musica Ltd to carry out a hot review of the audit which is in progress for the year ended 31 March 2X11. E-musica have...
-
Firms HL and LL are identical except for their financial leverage ratios and the interest rates they pay on debt. Each has $13 million in invested capital, has $1.95 million of EBIT, and is in the...
-
Below is a sample of the data in the file NFLAttendance which contains the 32 teams in the National Football League, their conference affiliation, their division, and their average home attendance....
-
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...
-
Tobacco Leaf Treehouses, Inc., a Kentucky company, has determined that a majority of its customers are located in the Pennsylvania area. It therefore is considering using a lockbox system offered by...
-
Your firm has an average receipt size of \($50.\) A bank has approached you concerning a lockbox service that will decrease your total collection time by three days. You typically receive 12,000...
-
Pete Moss, Inc., a large fertilizer distributor based in California, is planning to use a lockbox system to speed up collections from its customers located on the East Coast. A Philadelphia-area bank...
Study smarter with the SolutionInn App