Re: An efficient way of sequencing streams of integers



Chris <spam_me_not@xxxxxxxxxx> writes:

I have N streams of integers. Each stream returns integers, one at a
time, in ascending order. I need to merge the streams so that that the
next integer is always the lowest available integer across the
streams. The streams are of random length. The length of each stream
is known in advance.

This is just called a "merge" and it's treated in many basic
texts, include Knuth.

I'd suggest a binary heap as a first try.
--
Peter Seebach on managing engineers:
"It's like herding cats, only most of the engineers are already
sick of laser pointers."
.