# Lecture 12

This lecture consisted of a walk through of my solution to the turtle graphics interpreter problem, which is omitted in these notes so as not to poison this assignment for future years.

**Exercise 12.1** Write a queue simulator in C. You'll be asked to process several data files (zip archive), each of which consists of a sequence of lines, each of which has the ASCII representation of two floating point numbers, e.g.,

```
1.02 3.27
2.11 5.21
7.01 1.22
```

The first number consists of the arrival time into the queue. You are guaranteed that the arrival times are all (a) non-negative, and (b) occur in numerically sorted order from first to last. The second number is the servicing time for an element—how long it takes to from when it becomes the first element of the queue until it leaves.

Your program should simulate the behavior of the queue, and prepare a report that describes

- the maximum size of the queue,
- the maximum wait time, i.e., the longest time someone spends in the queue between arrival and the beginning of processing (note here that a person's own servicing time does not count towards their wait time.

In the unlikely event of a simultaneous departure/arrival, you should process the departure first. This is relevant only as regards reporting of maximum queue length.

An excellent discussion and implementation of a cons-based queue can be found Section 3.3.2 in Abelson & Sussman's Structure and Interpretation of Computer Programs, albeit written in Scheme. I strongly recommend working through Abelson & Sussman as a break-week activity.