Merge Algorithm
Merge algorithms are a family of algorithms that run sequentially over multiple sorted lists, typically producing more sorted lists as output. This is well-suited for machines with tape drives. Use has declined due to large random access memories, and many applications of merge algorithms have faster alternatives when a random-access memory is available.
The general merge algorithm has a set of pointers p0..n that point to positions in a set of lists L0..n. Initially they point to the first item in each list. The algorithm is as follows:
While any of p0..n still point to data inside of L0..n instead of past the end:
- do something with the data items p0..n point to in their respective lists
- find out which of those pointers points to the item with the lowest key; advance one of those pointers to the next item in its list
Read more about Merge Algorithm: Analysis, Language Support, Parallel Merge
Famous quotes containing the word merge:
“We dont know when our name came into being or how some distant ancestor acquired it. We dont understand our name at all, we dont know its history and yet we bear it with exalted fidelity, we merge with it, we like it, we are ridiculously proud of it as if we had thought it up ourselves in a moment of brilliant inspiration.”
—Milan Kundera (b. 1929)