Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What is the relation of physical mathematics with examples?

Answered: 1 week ago

Question

What are oxidation and reduction reactions? Explain with examples

Answered: 1 week ago