Data Merging Data Structures

0
29

The simplest method of merging two files of data would be to concatenate (join together) and then sort the new list. However this is not a practical solution when each individual file could consist of thousands of records. The simple method shown can be used on

files containing any number of records. First sort each file into the same ascending or descending order. Note there is a dummy record at the end-of-file (EOF) which is a marker to stop the merge process for that file. Each pair of records is then compared and the greater of the two, merged to the output file #3. A much faster method of merging files is the ‘Merge-Sort’ (not shown). This process involves two files to be merged ‘A’ and ‘B’ and two output files ‘C’ and ‘D’. The result of the comparison of records from ‘A’ and ‘B’ is moved to build sequential lists on files ‘C’ and ‘D’. This continues until ‘A’ and ‘B’ files no longer contain records. Files ‘C’ and ‘D’ then become the inputs and the process is repeated, the result of the comparison is moved to a final output file. What is actually occurring is strings of sequential record keys are being assembled, first onto one file until an out-of-sequence item is found, it then begins to construct a new sequential list in the other file. This is repeated until all the keys are in sequence.

LEAVE A REPLY

Please enter your comment!
Please enter your name here