IBM 1130 User Manual page 596

Computing system
Hide thumbs Also See for 1130:
Table of Contents

Advertisement

Section
Subsections
Page
75
30
I
10
03
Input and Pass 1
13
r
13
13
13
13
13
69
69
56
56
56
56
56
56
r69
L-
02
02
02
02
02
02 )~69
08
08
08
08
08
08
r
69
L-
21
21
21
21
21
21~69
Pass 2
13
r
13
13
13
13
56
56
r
02
02
02
02
02
56
)~
08
08
08
08
08
56
r
21
21
21
21
21
56
69
69
69
69
69
Pass 3
Output
13
r
02
02
02
02
02
13
08
08
08
08
08
r
13
r
13
13
21
21
21
21
21
56
56
56
56
56
69
69
69
69
69
The size of the file is of great importance, since
the total number of comparisons and interchanges
increases roughly with the square of the number of
records in the file.
Merging
Merging is the process of combining several
sequences of records to form a single specified
sequence. The same rules by which sequences are
combined may also be used to form sequences (of
two or more items). Thus, the merging process
has, essentially, a dual nature: it can be used for
creating sequences (usually in an internal sort),
and it is also capable of reducing previously created
sequences to one (usually in an external sort). This
dual capability contrasts with the selection and
exchange techniques described thus far, which are
useful prim arily for internal sorting of relatively
short files of records. The versatility, speed, and
simplicity of merging make it one of the most widely
used sorting techniques.
There are two basic methods of merge sorting:
(1) straight or standard merging, with fixed-length
sequences, and (2) natural merging, with variable-
length sequences, or strings.
(The words "sequence"
and "string" are often used interchangeably in
merging terminology.)
In straight merging, the input file is distributed
initially into two or more work areas, depending
upon the number of sequences to be combined dur-
ing each merge (that is, the order of merge).
For
example, in a method of two-way straight merging,
the first merge pass alternates between two stor-
age areas to form strings of two records, one from
each area. Subsequent passes double the length
of the strings each time (for example, 4, 8, 16,
etc.), until the last pass produces a single sequence
of all the records. The length of the strings during
each pass and the number of passes are fixed.
The natural merge sort takes advantage of
"natural" sequences in the original file, w hi ch
occur with a certain "probable" frequency. The
length of the strings on each pass is no longer fixed,
but depends upon the existing sequences. The total
number of passes required to sort a given file, then,
also depends on the number of natural sequences in
the original file.
For a file that is in correct
sequence, only a single pass is required --- to verify
that sequence. In the worst case, the number of
passes is the same as for straight merging.

Advertisement

Table of Contents
loading

Table of Contents