Using the heap implementation of a priority queue from Project 1, implement a program that keeps track
Question:
Using the heap implementation of a priority queue from Project 1, implement a program that keeps track of the user’s list of prioritized chores.
Data from Project 1
Using a heap, implement the priority queue ADT from Section 7.4. You can store the heap in arrays, similar to the solution to Self-Test Exercise 1. To have FIFO behavior for elements with equal priority, you should have a third array called entered. The value of entered[i] tells when the data in node number i entered the priority queue. For example, the first element added has an entered value of 1, the second element has an entered value of 2, and so on. When you are comparing two elements with equal priority, use the entered value to “break the tie” (so that if two elements have the same priority number, then the one with the earlier entered value will come out of the priority queue first).
Make sure you keep track of how many elements are in the heap so that if the size of the heap reaches the size of the arrays, you can increase the size of the arrays.
Step by Step Answer:
include using namespace std Priority queue class using heap implementation class PriorityQueue priva...View the full answer
Students also viewed these Computer science questions
-
Using a heap, implement the priority queue ADT from Section 7.4. You can store the heap in arrays, similar to the solution to Self-Test Exercise 1. To have FIFO behavior for elements with equal...
-
Give a complete implementation of a priority queue using the idea from the direct implementation. Priority Queue ADTA Direct Implementation If the number of possible priorities is large, then an...
-
write a job description for Bill Ryan's job. What other information would you need to write a better job description? Remember, this is a job description, not a help wanted ad. Please do your own...
-
The unadjusted trial balance of Simple Consulting Services as at December 31, 2021 is as follows: Cash Accounts receivable Prepaid insurance Supplies inventory Office equipment Accumulated...
-
Complete the frequency table that corresponds to the frequency table in the exercise indicated by adding the relative frequency and cumulative relative frequency columns, accurate to 3 decimals....
-
Supp osesupplyinamarketisQS=13PPS= 3Q,(S)wherePisthepriceandQisthequantity.Thereisp erfectcomp etitioninthismarketanddemandisQD= 8012PPD=...
-
Monthly gold prices. The fluctuation of gold prices is a reflection of the strength or weakness of the US dollar. The table below shows monthly gold prices (dollars per troy ounce) from January 2015...
-
According to the value Line Investment Survey, the growth rate in dividends for Duke Energy for the previous 10 years has been 1.5 percent. If investors feel this growth rate will continue, what is...
-
The directors of Delicious Delights have asked to meet with you to discuss a couple of tax matters that concern them. i. The directors inform you that a competitor has been making false statements...
-
Three-phase lines, each with an impedance of 0.8 +13.0 22. deliver 112 kVA at a power factor of 0.9, lagging, and at 1 kV to a balanced three-phase load (a) Draw a per-phase schematic for the system,...
-
The heap in this chapter is referred to as a maxheap because the highest priority value is also the maximum value. Implement the heap as a minheap, in which the entry of the node with the highest...
-
Reimplement the binary search using a loop and no recursion. If you are familiar with Javas Comparable interface, then your implementation search an array of Comparable objects rather than an array...
-
Identify the effect of unbalanced voltage on motor operation and the remedy to maintain its normal service life.
-
Design a clocked D flip-flop, using a modified ECL circuit design, such that the output becomes valid on the negative-going edge of the clock signal.
-
An L2 steel strap having a thickness of 0.125 in. and a width of \(2 \mathrm{in}\). is bent into a circular arc of radius \(600 \mathrm{in}\). Determine the maximum bending stress in the strap.
-
Cars traveling from Canada to the United States through the Thousand Islands Border Crossing must stop for US Customs and Immigration. During the stop, each passenger in the car must present a...
-
Gasoline is pumped through a 2 in. sch 40 pipeline upward into an elevated storage tank at $60^{\circ} \mathrm{F}$. An orifice meter is mounted in a vertical section of the line, which uses a DP cell...
-
Change the recurring costs in Problem and Exercise 3 to $40,000 and redo the analysis. Problem and Exercise 3 Assume you are put in charge of launching a new website for a local nonprofit...
-
Evaluate each of the following. (1 + 0.03) 25 /0.03
-
Reichenbach Co., organized in 2018, has set up a single account for all intangible assets. The following summary discloses the debit entries that have been recorded during 2018 and 2019. Instructions...
-
In this exercise we look at memory locality properties of matrix computation. The following code is written in C, where elements within the same row are stored contiguously. Assume each word is a...
-
Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address references, given as word addresses. 3, 180, 43, 2, 191, 88, 190, 14,...
-
For a direct-mapped cache design with a 32-bit address, the following bits of the address are used to access the cache. 1. What is the cache block size (in words)? 2. How many entries does the cache...
-
Show that the convexity for a zero coupon bond with m payments per year is (m) n(n + -)(1+ m m
-
Abdul Canarte , a Central Bank economist, noticed that the total group purchasing basket of goods (CPI) has gone from $149,740.00 to $344,460.00 in 8 years. With monthly compounding, what is the...
-
ABC Corporation expects sales next year to be $50,000,000. Inventory and accounts receivable (combined) will increase $8,000,000 to accommodate this sales level. The company has a profit margin of 6...
Study smarter with the SolutionInn App