Question
Make a priority queue. A priority queue is a data structure that adds items to a list but removes them in an ordered manner determined
Make a priority queue. A priority queue is a data structure that adds items to a list but removes them in an ordered manner determined by the programmer. One way to apply a priority queue is a Grocery List. When you think about it, we often go shopping with a budget. Sometimes, we cannot get everything on our shopping list due to our budget. So, we add items that we need more than others or we add the least expensive items to maximize how much of our list we purchase. Therefore our grocery list is in effect a priority queue: The list has items pushed onto list. Then, as items are popped from the list, they are pushed into the shopping cart. Your budget and need determines what things are left on the list.
EXAMPLE OUTPUT
Grocery List Rules 1. 2. 3. The shopping list should also contain a running total of everything in the list. Each List should contain a title We will add 10 items to our Shopping list. Each Item will have a name and a price associated with it. Gallon of Milk $6.99 Dozen Eggs $5.69 Peanut Butter $4.99 Chicken Strips $6.99 Ice Cream - $4.00 Cereal $3.98 3lbs of Apples $4.11 Gift Card $10 10 pack of socks $19.78 48 count AA Batteries $14.49 4. In order to make the list to operate as a priority queue, anything added to the List needs to be sorted, from the lowest price at the top of the list to the highest price at the bottom of the list. Then when removing items from the list, remove the item with the lowest price. Grocery.h 1. In the private section of your Grocery Class, have the list name A structure for the item information, including the name of the item and the price of the item, and a linker to the next item Access to the top of the list The size of the list The running total of the list. a. b. C. d. e. 2. In the public section of your Grocery Class, have Constructors and Deconstructors An accessor methods for: (1) the size of the list, (2) the name of the list, (3) the name of the item at the top of the list, and (4) the price of the item at the top of the list Mutator methods for pushing and popping an item Overloaded operator for () that takes a string and double and pushes the items to the list a. b. C. d
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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