c. f3(): 2.5 marks - Serve all requests in the requestQueue
You should perform the pair of operations deQueue() and rent() for all elements in the requestQueue.
2
The expected output used to test your code are as follows:
Data List: (001,0,10,200) (003,0,3,70) (004,0,4,100) (005,0,3,70)
Request: (1,100) (12,500) (4,50) (4,400)
Data List: (001,0,10,200) (003,1,3,70) (004,1,4,100) (005,0,3,70)
Request: Empty
Explaination:
o Similar to the f2() function, the request (1,100) will be served in room 003.
o The request (12,500) will not find a suitable Room due to the large number of people (size=12), which exceeds the size of all available rooms.
o The request (4,50) also fails to find a room because it carries too little money (price-50), specifically less than the price of the cheapest room (price=70).
o The request (4,400) has two suitable rooms: 001 (price-200) and 004 (price=100),so room 004 is chosen because it has the lower price.
o As a result, rooms 003 and 004 are rented, and the requestQueue is empty.
d. f4(): 2.5 marks - Count the available Rooms after serve all requests in the requestQueue You should: (1) perform the pair of operations deQueue() and rent() for all elements in the requestQueue, then (2) count the available Rooms with status = 0.
Zoom
+ 93%
Close