Ford-Johnson (AKA) merge-insertion sort, designed to perform as few comparisons as possible to sort a collection.
make
./PmergeMe 29 403 381 0 9
- Pairing elements: The algorithm first divides the array into pairs of elements.
- Selecting larger elements: It then identifies the larger element within each pair.
- Sorting larger elements: These larger elements are treated as a sub-array and sorted in ascending order.
- Inserting remaining elements: Here's where the Jacobsthal sequence comes in. The Jacobsthal numbers determine the positions where the remaining elements (those not chosen as the larger elements in the pairs) are inserted into the sorted sub-array. The first remaining element is inserted at the beginning of the sorted sub-array. Subsequent remaining elements are inserted at positions determined by the Jacobsthal sequence relative to the previously inserted elements. This ensures they are inserted in the correct sorted order.
This steps breakdown was generated by Google Gemini
Note: You can use other index checking serie other than Jacobsthal.