[Home]History of Merge

HomePage | Recent Changes | Preferences

Revision 6 . . (edit) December 12, 2001 7:30 am by Taw [format fix]
Revision 5 . . (edit) December 12, 2001 7:22 am by Taw [format fix]
Revision 4 . . (edit) October 29, 2001 3:36 pm by Kragen [Added links.]
Revision 1 . . October 26, 2001 5:01 am by (logged).157.137.xxx
  

Difference (from prior major revision) (minor diff, author diff)

Changed: 1c1
Merge is a family of algorithms that run sequentially over multiple sorted lists, typically producing more sorted lists as output. This makes them great for machines with tape drives. They're not as widely-used as they used to be, because now we have large random access memories, and many applications of merge algorithms have faster alternatives when you have a random-access memory that holds all your data.
Merge is a family of algorithms that run sequentially over multiple sorted lists, typically producing more sorted lists as output. This makes them great for machines with tape drives. They're not as widely-used as they used to be, because now we have large random access memories, and many applications of merge algorithms have faster alternatives when you have a random-access memory that holds all your data.

Changed: 9c9
The classic merge (the one used in merge sort) outputs the data item with the lowest key at each step; given some sorted lists, it produces a sorted list containing all the elements in any of the input lists.
Merge algorithms generally run in time proportional to the sum of the lengths of the lists; merge algorithms that operate on large numbers of lists at once will multiply the sum of the lengths of the lists by the time to figure out which of the pointers points to the lowest item, which can be accomplished with a heap-based priority queue in O(lg n) time, for O(m lg n) time (where m is the sum of the lengths of the lists).

Added: 10a11,17
The classic merge (the one used in merge sort) outputs the data item with the lowest key at each step; given some sorted lists, it produces a sorted list containing all the elements in any of the input lists, and it does so in time proportional to the sum of the lengths of the input lists.

Merge can also be used for a variety of other things:
* given a set of current account balances and a set of transactions, both sorted by account number, produce the set of new account balances after the transactions are applied; this requires always advancing the "new transactions" pointer in preference to the "account number" pointer when the two have equal keys, and adding all the numbers on either tape with the same account number to produce the new balance.
* produce a sorted list of records with keys present in all the lists (equijoin); this requires outputting a record whenever the keys of all the p0..n are equal.
* similarly for finding the largest number on one tape smaller than each number on another tape (e.g. to figure out what tax bracket each person is in).
* similarly for computing set differences: all the records in one list with no corresponding records in another.

HomePage | Recent Changes | Preferences
Search: