A Pizzeria offers M different kinds of pizzas (let’s assume that the pizza kind is a number between 0 and M-1)

A Pizzeria offers M different kinds of pizzas (let’s assume that the pizza kind is a number between 0 and M-1). In order to serve its clients quickly, the pizzeria cooks pizzas in advance. Let’s say that at a given moment, the pizzeria has N pizzas ready of different kinds, with N>>M. When a client orders a pizza of a given kind, it receives the pizza of that kind that has been cooked since the longest time (to avoid wasting pizzas). A client has also the possibility of ordering a surprise pizza, that is the client does not choose the kind of pizza but gets the pizza at a lower price. In that case, the pizzeria gives to the client the oldest pizza of all pizzas prepared

Algorithm for getSurprisePizza()

The time of each operation should not depend on the total number of pizzas N; otherwise. You may use any data structures seen in class to implement your data structure. Your algorithm can be in pseudocode or Java-like code. You may call system.currentTime() when you make a pizza. You may assume the existence of a class Pizza with the following methods: getKind() getTime()

The only way to get a time complexity not depending of the total number of pizzas is to create an Array of queues for example. However, I am stuck after that. I have to call a time function getTime() to see what pizza is the older. Do I need to make an array of times after? and those times will be linked to a certain pizza like dictionaries in python? Some ideas would be nice

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?