Internal Sorting

Internal Sorting is a type of sorting algorithm that done their sorting within the capacity of the main memory. Although it could be quite fast since the operation is done in the RAM speed, internal sorting has a limitation on handling files that store in physical drive due to the inefficiency of I/O access. See 202203102010 for that regard.

There are several algorithms that are optimal for internal sorting:

Links to this page
  • Two-way Merge

    Two-way Merge splits the file contents into parts where their size, \(M\), could be held by the main memory. Those parts will be sorted using one of the 202203102004 and we will pair those parts into runs which will be stored into two separate drives or tapes. We will merge two parts by comparing them sequentially until we have hit the end of the run. Follow the recursive rule, we will repeat the steps stated before until we have obtained a sorted result.

  • Polyphase Merge

    Polyphase Merge is used when there are only \(k + 1\) drives or tapes where \(k\) represent an even number. It will first split the file contents into runs that resemble Fibonacci number. Note that all the runs have been sorted using one of the 202203102004.

  • K-way Merge

    Like #202203102127, it splits the file contents into parts with size of \(M\) which will be sorted using one of the 202203102004.

#algorithm #sorting #memory