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
a)wrte an algorithm, for each of the following operations:
addPizza(kind)
getPizza(kind)
getSurprisePizza()
b)Determne the Big Oh running time for each implementation of these operations.
write your algorithms in Java-like code.
You may call system.currentTime() when you create a pizza.
You may assume the existence of a class Pizza with the following methods:
getKind()
getTime()