Queues

Course links

Exercise 1

Add to the queue an additional operation, print, activated by the ':print message, that displays each of the elements of the queue on a separate line (without actually removing any of them from the queue). Make sure not to print the dummy header.

Exercise 2

Define and test a procedure named merge-queues that takes as arguments two queues of real numbers, both of which must be in ascending numerical order from front to rear, and returns a single queue containing the elements of both of the given queues, again in ascending numerical order.

Exercise 3

Using deep recursion, write a procedure that creates an empty queue, then traverses a tree of symbols and puts each symbol that it encounters into the queue, and finally uses the print operation added in the previous exercise to display the contents of the queue (which should be the yield of the tree).

Acknowledgements

The principal author of this lab is Professor Henry Walker.