Queues
November 1, 2013
One of the basic data structures in computer science is the queue, in which items are inserted into the data structure and retrieved in the order in which they were inserted; the standard operations on a queue are enqueue, dequeue, and isEmpty.
Your task is to write functions to implement a queue. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Implemented in Go.
Implementation in SML.
Okasaki “banker’s queues” in Haskell:
I forgot to mention above that if the size operation is not needed, it’s possible to save a bit of space by storing only the difference between the front and rear lengths, rather than the lengths themselves.