Problems with a FIFO pattern, and writing code that solves them: merging sorted queues, recursion on a queue