- Published on
The Algorithm Design Manual (3rd) Exercise Solution 'E3-6'
Table of Contents
Introduction
This series is my solutions for algorithm exercises in'The Algorithm Design Manual' 3rd edition.
It's my solutions, not model answers, so if you find some mistakes or more sophisticated solutions, please post in comment area below.
Repository
Exercise 3-6
Question
Suppose you seek to maintain the contents of a refrigerator so as to minimize food spoilage. What data structure should you use, and how should you use it?
Solution
Queue is the most appropriate.
Assuming the time it takes for food to spoil is the same, food put into the refrigerator earlier is more likely to spoil than food put in later. So it's desirable for that put earlier to be comsumed.