Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Propose a data structure to use for the following situation. Justify your choices. You do not need to give complete code, but it should be
Propose a data structure to use for the following situation. Justify your
choices. You do not need to give complete code, but it should be clear
how your solution is intended to work. You can use all data structures and
operations on these data structures that have been described in lectures as
"blackbox" without giving an implementation.
You want to write a simple "unpaid bill manager". New bills arrive
frequently. For each bill you also have a deadline for paying the bill. On
arrival of a bill you want to add the new bill to your structure. You always
want to pay the bill with the earliest deadline.
You also may want to know the total amount to pay for all bills with
deadlines less than or equal to a time That is you want to efficiently
query your data structure to return the total amount to pay up to any time
You may assume that the bill deadlines are integers day numbers and
at most one bill will arrive with a deadline on any day.
Your "unpaid bill manager" should be able to:
Add a new unpaid bill to your structure. Note that the deadlines of
new bills are not necessarily in time order.
Find the bill with the earliest deadline, output it and delete it from
the structure.
Calculate the total cost of bills with deadlines up to for any time
What is the time required for the three basic operations add a new bill,
find the next bill to pay, and calculate total amount of bills up to time
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