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

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 numbers and puts each number that it encounters into the queue, and finally uses the print operation added in exercise 1 to display the contents of the queue.

Acknowledgements

The principal author of this lab is Professor Henry Walker.