Sorted List Merging via Array Pair Alternation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for merging sorted lists, such as the priority queue method, are inefficient and complex, particularly for modern processors that excel in sequential operations.
Innovation Solution
The method uses a pair of arrays to merge multiple input sorted lists in multiple phases, where the first array is contiguously populated with input sorted lists, and intermediary merged lists alternate between the arrays, optimizing the merging process through sequential read and write operations.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If the priority queue method is used to merge sorted lists, then the merging can be performed with multiple input lists, but the processing efficiency is low and the operation complexity is high
Solution Approach 1:
The merging process is divided into multiple phases, where each phase merges a subset of sorted lists. In the first phase, input lists are merged in pairs; in subsequent phases, the intermediate results are merged with remaining input lists. This segmentation reduces the complexity of each individual merging operation while maintaining overall efficiency.
Solution Approach 2:
The algorithm uses periodic phases of merging operations, where each phase processes a specific subset of lists. The merging alternates between different combinations of lists across phases, creating a periodic pattern of operations that optimizes processor utilization and reduces overhead.
2Productivity
If the priority queue method is used, then multiple sorted lists can be merged, but it does not leverage sequential read and write operations efficiently
Solution Approach 1:
The algorithm uses two arrays (A and B) where data is copied between them in a sequential manner. Array A is filled with input lists, then merged results are copied to Array B, and this process repeats in alternating phases. This copying mechanism between arrays enables efficient sequential read and write operations that modern processors can execute rapidly.
Solution Approach 2:
The algorithm transitions from a single-dimensional priority queue structure to a two-dimensional array structure with alternating phases. By using two arrays and alternating between them across multiple phases, the algorithm creates an additional dimension of organization that enables sequential access patterns and improves cache utilization.
3Productivity
If traditional merging methods are used, then sorted lists can be merged, but the number of write operations is high
Solution Approach 1:
The algorithm merges multiple sorted lists by combining them in pairs during each phase, reusing the merged results from previous phases. This combining approach reduces the total number of write operations compared to processing each list separately, as intermediate merged results are preserved and reused in subsequent phases.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
The formulation of a merged sorted list from multiple input sorted lists in multiple phases using an array pair. Initially, the first array is contiguously populated with the input sorted lists. In the first phase, the first and second input sorted lists are merged into a first intermediary merged list within the second array. Each subsequent phase merges a prior intermediary merged list resulting from the prior phase and, a next input sorted list in the first array to generate a next intermediary merged list, or a merged sorted list if there or no further input in the first array. The intermediary merged lists alternate between the first array and the second array from one phase to the next phase.