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.

give an algorithm, for each of the following operations:

addPizza(kind)

getPizza(kind)

getSurprisePizza()

Determine the Big Oh running time for each implementation of these operations.

the time of each operation should not depend on the total number of pizzas N. the algorithms can be pseudocode or Java-like code. You may call system.currentTime() for the creation of a pizza. You may assume the existence of a class Pizza with the following methods: getKind() getTime()

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?