Hybrid Sorting Algorithm for Nearly Sorted Data

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing database sorting algorithms are inefficient for nearly sorted data, as they either require excessive memory or do not utilize data clustering characteristics, leading to suboptimal performance and high computational complexity.

Innovation Solution

A hybrid sorting method using two buffers, where one buffer preserves ordered records with a local insertion sort and the other handles out-of-order records with a more efficient algorithm, merging results to achieve efficient computational complexity and memory usage.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If a general-purpose sorting algorithm (e.g., merge sort, quick sort) is used to handle arbitrary input data, then the algorithm achieves good average and worst-case time complexity of O(N log N), but it does not exploit the clustering characteristics of nearly sorted data, resulting in suboptimal performance

Engineering Contradiction:
Improvesorting performanceVSAvoidability to handle different data characteristics
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The sorting system dynamically adapts its behavior based on the clustering factor of the input data. When the clustering factor indicates nearly sorted data, the system switches to an optimized path using insertion sort for clustered elements. For general unsorted data, it falls back to merge sort. This dynamic adaptation resolves the contradiction by making the algorithm both efficient for specific cases and versatile for general cases.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The invention introduces a clustering factor as a parameter to characterize input data. By evaluating this parameter, the system determines the appropriate sorting strategy. This parameter-based approach allows the algorithm to optimize performance for nearly sorted data while maintaining capability for general sorting scenarios.

Inventive Principle:
Principle #35Parameter changes

2Productivity

If insertion sort or library sort is used to exploit sorted input characteristics, then the algorithm achieves O(N) time complexity for sorted data, but it requires the entire input to fit in memory, which is not realistic for large datasets

Engineering Contradiction:
Improvesorting speed for sorted dataVSAvoidmemory usage
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The invention segments the input data into clustered portions and unclustered portions based on the clustering factor evaluation. Only the clustered portions are processed using the efficient insertion sort algorithm, while the overall sorting is performed using merge sort. This segmentation allows the use of memory-efficient insertion sort on relevant subsets without requiring the entire dataset to fit in memory.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Instead of applying insertion sort to the entire dataset (which would require excessive memory), the invention applies it partially only to the clustered portions identified by the clustering factor. This partial application achieves the O(N) efficiency benefit where applicable while avoiding the memory overhead for the entire dataset.

Inventive Principle:
Principle #16Partial or excessive action

3Productivity

If algorithms use extra memory to reduce computational complexity to O(N), then the best-case performance improves, but the memory overhead becomes as much as N times more, which is not scalable

Engineering Contradiction:
Improvebest-case sorting complexityVSAvoidextra memory allocation
Core Design Contradiction:
ProductivityVSQuantity of substance

Solution Approach 1:

The invention segments the sorting task into two parts: clustered data handling and general sorting. By separating these concerns, the algorithm only allocates minimal extra memory for the clustered portion processing, rather than allocating N times more memory for the entire dataset. This segmentation makes the approach scalable for large datasets.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The invention applies different sorting strategies to different portions of the data based on local characteristics. The clustering factor identifies local sortedness, and insertion sort is applied locally to those portions. This local optimization achieves better complexity where applicable without incurring global memory overhead.

Inventive Principle:
Principle #3Local quality

4Device complexity

If a one-size-fits-all sorting algorithm is used, then the implementation is simple and maintains good average complexity, but it cannot pick the best sorting strategy for different input characteristics, leading to non-optimal performance

Engineering Contradiction:
Improvealgorithm implementation complexityVSAvoidsorting efficiency
Core Design Contradiction:
Device complexityVSProductivity

Solution Approach 1:

The invention introduces dynamic behavior to the sorting algorithm by evaluating the clustering factor and selecting the appropriate sorting strategy. This dynamic approach maintains relative implementation simplicity while significantly improving sorting efficiency for nearly sorted data, resolving the contradiction between simplicity and efficiency.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS10089379B2Method for sorting data
Publication Date: 2018.10.02 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US10089379B2 patent drawing

AI summary

A sequence of one or more input objects are sorted by identifying a property that is exhibited by a sequence of one or more input objects, determining whether each input object from the sequence of one or more input objects exhibits the property, storing each of the one or more input objects into a buffer, wherein an input object is stored in a first buffer if it exhibits the property and an input object is stored in a second buffer if it does not exhibit the property, sorting each of the one or more input objects in each buffer, and merging the one or more input objects in each buffer into a sequence of one or more input objects.