Interstellar12312

Custom Stride Insertion Sort vs Standard Knuth Shell Sort vs Custom Insertion vs Standard Insertion

Feb 25th, 2026
88
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <chrono>
  4. #include <random>
  5. #include <algorithm>
  6. #include <iomanip>
  7.  
  8. // Benchmark: Custom Stride Insertion Sort vs Standard Knuth Shell Sort vs Custom Insertion vs Standard Insertion
  9. // Contact Email [email protected]
  10. // Created by I.A
  11.  
  12. // 1. Standard Insertion Sort
  13. void standardInsertionSort(std::vector<int>& arr) {
  14.     int n = arr.size();
  15.     for (int i = 1; i < n; i++) {
  16.         int key = arr[i];
  17.         int j = i - 1;
  18.         while (j >= 0 && arr[j] > key) {
  19.             arr[j + 1] = arr[j];
  20.             j--;
  21.         }
  22.         arr[j + 1] = key;
  23.     }
  24. }
  25.  
  26. // 2. Custom Jump Insertion Sort
  27. void customJumpSort(std::vector<int>& arr) {
  28.     int n = arr.size();
  29.     for (int i = 1; i < n; i++) {
  30.         int key = arr[i];
  31.         int j = i - 1;
  32.         while (j >= 0 && arr[j] > key) {
  33.             if (j >= 1) {
  34.                 arr[j + 1] = arr[j];
  35.                 if (arr[j - 1] > key) {
  36.                     arr[j] = arr[j - 1];
  37.                     j -= 2;
  38.                 } else {
  39.                     arr[j] = key;
  40.                     goto placed;
  41.                 }
  42.             } else {
  43.                 arr[j + 1] = arr[j];
  44.                 j--;
  45.             }
  46.         }
  47.         arr[j + 1] = key;
  48.         placed:;
  49.     }
  50. }
  51.  
  52. // 3. Custom Stride Insertion Sort
  53. void strideInsertionSort(std::vector<int>& arr) {
  54.     int n = arr.size();
  55.     for (int i = 1; i < n; i++) {
  56.         int key = arr[i];
  57.         int j = i - 16;
  58.  
  59.         // Step backward by 16
  60.         while (j >= 0 && arr[j] > key) {
  61.             // Shift the 16 elements ahead by one position
  62.             arr[j + 16] = arr[j + 15];
  63.             arr[j + 15] = arr[j + 14];
  64.             arr[j + 14] = arr[j + 13];
  65.             arr[j + 13] = arr[j + 12];
  66.             arr[j + 12] = arr[j + 11];
  67.             arr[j + 11] = arr[j + 10];
  68.             arr[j + 10] = arr[j + 9];
  69.             arr[j + 9]  = arr[j + 8];
  70.             arr[j + 8]  = arr[j + 7];
  71.             arr[j + 7]  = arr[j + 6];
  72.             arr[j + 6]  = arr[j + 5];
  73.             arr[j + 5]  = arr[j + 4];
  74.             arr[j + 4]  = arr[j + 3];
  75.             arr[j + 3]  = arr[j + 2];
  76.             arr[j + 2]  = arr[j + 1];
  77.             arr[j + 1]  = arr[j];
  78.             j -= 16;
  79.         }
  80.  
  81.         // Clean up the remaining 1 to 15 elements that weren't covered by the 16-stride
  82.         int k = j + 15;
  83.         while (k >= 0 && arr[k] > key) {
  84.             arr[k + 1] = arr[k];
  85.             k--;
  86.         }
  87.         arr[k + 1] = key;
  88.     }
  89. }
  90.  
  91. // 4. Standard Knuth Shell Sort
  92. void shellSort(std::vector<int>& arr) {
  93.     int n = arr.size();
  94.     int h = 1;
  95.  
  96.     // 1. Calculate the largest gap in the 3k+1 sequence that is < n
  97.     // Sequence: 1, 4, 13, 40, 121, 364, 1093...
  98.     while (h < n / 3) {
  99.         h = 3 * h + 1;
  100.     }
  101.  
  102.     // 2. Start with the largest gap and reduce it down to 1
  103.     while (h >= 1) {
  104.         for (int i = h; i < n; i++) {
  105.             int temp = arr[i];
  106.             int j;
  107.             // Standard gapped insertion sort
  108.             for (j = i; j >= h && arr[j - h] > temp; j -= h) {
  109.                 arr[j] = arr[j - h];
  110.             }
  111.             arr[j] = temp;
  112.         }
  113.         // Move to the next smaller gap in the sequence
  114.         h /= 3;
  115.     }
  116. }
  117.  
  118. int main() {
  119.     const int NUM_ELEMENTS = 1000;
  120.     const int NUM_TRIALS = 10000;
  121.  
  122.     std::random_device rd;
  123.     std::mt19937 gen(rd());
  124.     std::uniform_int_distribution<> dist(1, 100000);
  125.  
  126.     double totalStd = 0, totalJump = 0, totalStride = 0, totalShell = 0;
  127.  
  128.     std::cout << "Benchmarking... please wait." << std::endl;
  129.  
  130.     for (int t = 0; t < NUM_TRIALS; ++t) {
  131.         std::vector<int> source(NUM_ELEMENTS);
  132.         for (int& x : source) x = dist(gen);
  133.  
  134.         std::vector<int> d1 = source, d2 = source, d3 = source, d4 = source;
  135.  
  136.         // Standard
  137.         auto s1 = std::chrono::steady_clock::now();
  138.         standardInsertionSort(d1);
  139.         totalStd += std::chrono::duration<double>(std::chrono::steady_clock::now() - s1).count();
  140.  
  141.         // Jump
  142.         auto s2 = std::chrono::steady_clock::now();
  143.         customJumpSort(d2);
  144.         totalJump += std::chrono::duration<double>(std::chrono::steady_clock::now() - s2).count();
  145.  
  146.         // Stride
  147.         auto s3 = std::chrono::steady_clock::now();
  148.         strideInsertionSort(d3);
  149.         totalStride += std::chrono::duration<double>(std::chrono::steady_clock::now() - s3).count();
  150.  
  151.         // Shell
  152.         auto s4 = std::chrono::steady_clock::now();
  153.         shellSort(d4);
  154.         totalShell += std::chrono::duration<double>(std::chrono::steady_clock::now() - s4).count();
  155.  
  156.         // Logic check
  157.         if (!std::is_sorted(d2.begin(), d2.end()) || !std::is_sorted(d3.begin(), d3.end()) || !std::is_sorted(d4.begin(), d4.end())) {
  158.             std::cout << "CRITICAL ERROR: A Sort Failed!" << std::endl;
  159.             return 1;
  160.         }
  161.     }
  162.  
  163.     std::cout << "\n" << std::left << std::setw(25) << "Algorithm" << " | " << "Total Time (s)" << std::endl;
  164.     std::cout << "------------------------------------------------" << std::endl;
  165.     std::cout << std::setw(25) << "Standard Insertion" << " | " << std::fixed << std::setprecision(6) << totalStd << std::endl;
  166.     std::cout << std::setw(25) << "Custom Jump Sort"   << " | " << std::fixed << std::setprecision(6) << totalJump << std::endl;
  167.     std::cout << std::setw(25) << "Custom Stride Sort"        << " | " << std::fixed << std::setprecision(6) << totalStride << std::endl;
  168.     std::cout << std::setw(25) << "Standard Knuth Shell Sort"         << " | " << std::fixed << std::setprecision(6) << totalShell << std::endl;
  169.  
  170.     return 0;
  171. }
Advertisement
Comments
  • Bekboitoz
    201 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 38% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from Swapzone — instant swap).
  • Fexnovyn
    198 days
    # CSS 0.83 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1S1iTruSLkgEPO8QtTuo2twS4f2FoJ3_l0-p4GKqeAUY/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8.  
    9. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    10.  
    11. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification).
  • User was banned
  • User was banned
  • User was banned
  • Vocimko
    30 days
    # CSS 1.04 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. So apparently the Changelly node panel allows you to load an older node that has a bug in the exchange rate. The funny thing is that it uses a simple password, "admin," to access it.
    6.  
    7. This made me $13,000 in 2 days.
    8.  
    9. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 50% — they will simply correct the exchange rate.
    10.  
    11. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    12.  
    13. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from Changelly — instant swap).
  • User was banned
  • Xarqimoz
    14 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • User was banned
  • User was banned
  • Owpadko
    6 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=ypoqphmcqb
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment