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,0,3,70) (004,1,4,100) (005,1,3,70)
Request: Empty
Explaination:
Similar to the f2() function, the request (1,100) will be served in room 005.• 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 004 and 005 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.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,0,3,70) (004,1,4,100) (005,1,3,70)
Request: Empty
Available Room(s): 2
Explaination:
Similar to the function f3(), rooms 004 and 005 are rented. At that point, the Hotel has two available rooms: 001 and 003.
+ 100%
Zoom
Close