<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Emura Daisuke</title>
    <description>The latest articles on DEV Community by Emura Daisuke (@emuradaisuke).</description>
    <link>https://dev.to/emuradaisuke</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F147632%2F0ebf4ad7-79e4-42c0-bd27-d6b090264b48.jpg</url>
      <title>DEV Community: Emura Daisuke</title>
      <link>https://dev.to/emuradaisuke</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emuradaisuke"/>
    <language>en</language>
    <item>
      <title>Introducing a fast multi-threaded memory allocator</title>
      <dc:creator>Emura Daisuke</dc:creator>
      <pubDate>Thu, 03 Oct 2019 08:46:45 +0000</pubDate>
      <link>https://dev.to/emuradaisuke/introducing-a-fast-multi-threaded-memory-allocator-31di</link>
      <guid>https://dev.to/emuradaisuke/introducing-a-fast-multi-threaded-memory-allocator-31di</guid>
      <description>&lt;p&gt;Liquid syntax error: 'raw' tag was never closed&lt;/p&gt;
</description>
      <category>programming</category>
      <category>cpp</category>
      <category>memory</category>
    </item>
    <item>
      <title>Introduction of fast differential sorting algorithm "Homura-Shiki"</title>
      <dc:creator>Emura Daisuke</dc:creator>
      <pubDate>Mon, 01 Apr 2019 05:56:37 +0000</pubDate>
      <link>https://dev.to/emuradaisuke/introduction-of-fast-differential-sorting-algorithm-homura-shiki-105g</link>
      <guid>https://dev.to/emuradaisuke/introduction-of-fast-differential-sorting-algorithm-homura-shiki-105g</guid>
      <description>&lt;h1&gt;
  
  
  焔式(Homura-Shiki)
&lt;/h1&gt;

&lt;p&gt;Homura-Shiki is a new method of differential sort algorithm that applies merge sort.&lt;br&gt;
For a sorted array, focus on the place where the value change is made and sort fast.&lt;/p&gt;

&lt;p&gt;It has the following features.(Let D be the changed range)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comparison sort&lt;/li&gt;
&lt;li&gt;Stable sort&lt;/li&gt;
&lt;li&gt;External area: N&lt;/li&gt;
&lt;li&gt;Average time: O ((D log D) + N)&lt;/li&gt;
&lt;li&gt;Worst time: O ((D log D) + N)&lt;/li&gt;
&lt;li&gt;Best time: O (D)&lt;/li&gt;
&lt;li&gt;Recursion: None&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/EmuraDaisuke/SortingAlgorithm.HomuraShiki"&gt;Homura-Shiki(MIT License)&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic algorithm
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Change the value at any range in the sorted array.&lt;/li&gt;
&lt;li&gt;Perform comparison stable sorting on the change range.&lt;/li&gt;
&lt;li&gt;Merge three parcels in "Forward Range, Change Range, Rearward Range".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Change the value at any range in the sorted array.
0 2 3 4 5 6 7 9|Sorted array
    ↓↓↓
0 2|8 1 3|6 7 9|
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Perform comparison stable sorting on the change range.
0 2|8 1 3|6 7 9|
    ↓↓↓
0 2|1 3 8|6 7 9|
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Merge three parcels in "Forward Range, Change Range, Rearward Range".
0 2|1 3 8|6 7 9|

02   Forward Range
138  Change Range
679  Rearward Range

012    Merge with change range until there is no forward range.(Forward part)
36789  Merge the remainder of the change range with the rearward range.(Rearward part)

01236789  Join forward part and rearward part.(sort complete)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Build &amp;amp; Test
&lt;/h1&gt;

&lt;p&gt;The following environment has been verified.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows 10 Pro 64bit&lt;/li&gt;
&lt;li&gt;Core i7-8700 3.20GHz&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prepare &lt;a href="https://github.com/EmuraDaisuke/SortingAlgorithm.HayateShiki"&gt;Hayate-Shikli&lt;/a&gt; and &lt;a href="https://github.com/EmuraDaisuke/SortingAlgorithm.SetsunaShiki"&gt;Setsuna-Shiki&lt;/a&gt; in the sibling directory and build.  &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Msvc&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Microsoft(R) C/C++ Optimizing Compiler Version 19.16.27027.1 for x64&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cl Main.cpp -Ox -EHsc -Fe:TestMsvc.exe
TestMsvc.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;clang++&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;clang version 8.0.0 (tags/RELEASE_800/final)&lt;br&gt;
Target: x86_64-w64-windows-gnu&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clang++ Main.cpp -O3 -o TestClang++.exe
TestClang++.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;g++&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;gcc version 8.3.0 (Rev2, Built by MSYS2 project)&lt;br&gt;
Target: x86_64-w64-mingw32&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;g++ Main.cpp -O3 -o TestG++.exe
TestG++.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Average benchmark
&lt;/h1&gt;

&lt;p&gt;The following is the case of changing the random range of the sorted array to a random value.&lt;br&gt;
The unit is seconds, the lower the number, the faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Msvc&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Homura-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;0.00031643&lt;/td&gt;
&lt;td&gt;0.00016890&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00014270&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000,000&lt;/td&gt;
&lt;td&gt;0.05004999&lt;/td&gt;
&lt;td&gt;0.02833382&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02414271&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000,000&lt;/td&gt;
&lt;td&gt;3.43509980&lt;/td&gt;
&lt;td&gt;3.48550165&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.55574413&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;clang++&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Homura-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;0.00027717&lt;/td&gt;
&lt;td&gt;0.00020017&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00015642&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000,000&lt;/td&gt;
&lt;td&gt;0.03866672&lt;/td&gt;
&lt;td&gt;0.02881882&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02255046&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000,000&lt;/td&gt;
&lt;td&gt;3.38201222&lt;/td&gt;
&lt;td&gt;3.64178056&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.60998679&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;g++&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Homura-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;0.00029155&lt;/td&gt;
&lt;td&gt;0.00020019&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00014887&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000,000&lt;/td&gt;
&lt;td&gt;0.04052708&lt;/td&gt;
&lt;td&gt;0.02760306&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02054782&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000,000&lt;/td&gt;
&lt;td&gt;3.58270940&lt;/td&gt;
&lt;td&gt;3.45231729&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.36870185&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Limited condition benchmark
&lt;/h1&gt;

&lt;p&gt;The following is sorted by the array [100,000,000].&lt;br&gt;
The unit is seconds, the lower the number, the faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best case
&lt;/h2&gt;

&lt;p&gt;When the range is specified randomly without changing the value for the sorted array.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Homura-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Msvc&lt;/td&gt;
&lt;td&gt;0.23993706&lt;/td&gt;
&lt;td&gt;1.30073792&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.01059685&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;clang++&lt;/td&gt;
&lt;td&gt;1.04052412&lt;/td&gt;
&lt;td&gt;1.52173567&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.01611595&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g++&lt;/td&gt;
&lt;td&gt;1.34400042&lt;/td&gt;
&lt;td&gt;1.31273356&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.01510180&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Finally
&lt;/h1&gt;

&lt;p&gt;How was it?  &lt;/p&gt;

&lt;p&gt;We came up with the idea of ​​differential sorting, in terms of the fact that sorting does not always have to be done in its entirety.&lt;br&gt;
Although the comparison between std::sort and std::stable_sort, which is an overall sort, and Homura-Shiki, which is an diff sort, is not fair, it should be used to determine the usefulness of diff sort.&lt;/p&gt;

&lt;p&gt;I think that it could be shown that sorting can be done faster by devising it.&lt;br&gt;
As a guideline for operation, if (D &amp;lt;(N / 2)), differential sorting, otherwise it is a feeling that the whole sort is good.&lt;/p&gt;

&lt;p&gt;The sort algorithm is still romantic.&lt;/p&gt;

&lt;p&gt;Thanks for watching!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Proposal of a new method, Introduction of differential sort algorithm "Setsuna-Shiki"</title>
      <dc:creator>Emura Daisuke</dc:creator>
      <pubDate>Sun, 24 Mar 2019 15:25:31 +0000</pubDate>
      <link>https://dev.to/emuradaisuke/proposal-of-a-new-method-introduction-of-differential-sort-algorithm-setsuna-shiki-2alp</link>
      <guid>https://dev.to/emuradaisuke/proposal-of-a-new-method-introduction-of-differential-sort-algorithm-setsuna-shiki-2alp</guid>
      <description>&lt;h1&gt;
  
  
  刹那式(Setsuna-Shiki)
&lt;/h1&gt;

&lt;p&gt;Setsuna-Shiki is a new method of differential sorting algorithm that applies bisection insertion sorting.&lt;br&gt;
For a sorted array, focus on the place where the value change is made and sort very fast.&lt;/p&gt;

&lt;p&gt;It has the following features.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comparison sort&lt;/li&gt;
&lt;li&gt;Stable sort&lt;/li&gt;
&lt;li&gt;External area: None&lt;/li&gt;
&lt;li&gt;Average time: O (log N)&lt;/li&gt;
&lt;li&gt;Worst time: O (log N)&lt;/li&gt;
&lt;li&gt;Best time: O (2)&lt;/li&gt;
&lt;li&gt;Recursion: None&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/EmuraDaisuke/SortingAlgorithm.SetsunaShiki"&gt;Setsuna-Shiki(MIT License)&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic algorithm
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Change the value at any position in the sorted array.&lt;/li&gt;
&lt;li&gt;If (Changed position value &amp;lt; value below change position), the lower range is binary-searched and rotate from change position to search position.&lt;/li&gt;
&lt;li&gt;If (value above change position &amp;lt; Changed position value), the upper range is binary-searched and rotate from change position to search position.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Change the value at any position in the sorted array.
0 1 2 4 5 6 7 9|Sorted array
        ↓
0 1 2 4 x 6 7 9|Change the value at any position
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If (Changed position value &amp;lt; value below change position), the lower range is binary-searched and rotate from change position to search position.
0 1 2 4 5 3 7 9|In the case of [5]=3
0 1 2 4 5|. . .|Binary search the lower range
. . .|3 4 5|. .|Rotate from change position to search position
0 1 2 3 4 5 7 9|Sort result
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If (value above change position &amp;lt; Changed position value), the upper range is binary-searched and rotate from change position to search position.
0 1 8 4 5 6 7 9|In the case of [2]=8
. . .|4 5 6 7 9|Binary search the upper range
. .|4 5 6 7 8|.|Rotate from change position to search position
0 1 4 5 6 7 8 9|Sort result
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Points devised
&lt;/h1&gt;

&lt;p&gt;Even if binary search is performed to the area where the same value is continuous, stability is maintained.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The binary search in the lower range searches the end of the continuous area.&lt;/li&gt;
&lt;li&gt;The binary search in the upper range searches the beginning of a continuous area.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Build &amp;amp; Test
&lt;/h1&gt;

&lt;p&gt;The following environment has been verified.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows 10 Pro 64bit&lt;/li&gt;
&lt;li&gt;Core i7-8700 3.20 GHz&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Msvc&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Microsoft(R) C/C++ Optimizing Compiler Version 19.15.26732.1 for x64&lt;br&gt;
Microsoft (R) Incremental Linker Version 14.15.26732.1&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cl Main.cpp -Ox -EHsc -Fe:TestMsvc.exe
TestMsvc.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;clang++&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;clang version 7.0.0 (tags/RELEASE_700/final)&lt;br&gt;
Target: x86_64-w64-windows-gnu&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;clang++ Main.cpp -O3 -o TestClang++.exe
TestClang++.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;g++&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;gcc version 8.2.0 (Rev3, Built by MSYS2 project)&lt;br&gt;
Target: x86_64-w64-mingw32&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;g++ Main.cpp -O3 -o TestG++.exe
TestG++.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Average benchmark
&lt;/h1&gt;

&lt;p&gt;The following is the case of changing the random position of the sorted array to a random value.&lt;br&gt;
The unit is seconds, the lower the number, the faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Msvc&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Setsuna-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;0.00007095&lt;/td&gt;
&lt;td&gt;0.00004502&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00000115&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000,000&lt;/td&gt;
&lt;td&gt;0.00975892&lt;/td&gt;
&lt;td&gt;0.00698905&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00009487&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000,000&lt;/td&gt;
&lt;td&gt;0.27018098&lt;/td&gt;
&lt;td&gt;1.26169269&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.01670523&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;clang++&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Setsuna-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;0.00006162&lt;/td&gt;
&lt;td&gt;0.00006669&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00000050&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000,000&lt;/td&gt;
&lt;td&gt;0.00775640&lt;/td&gt;
&lt;td&gt;0.00978430&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00006938&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000,000&lt;/td&gt;
&lt;td&gt;0.99487866&lt;/td&gt;
&lt;td&gt;1.46673092&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.01248609&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;g++&lt;/strong&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Array&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Setsuna-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;0.00009420&lt;/td&gt;
&lt;td&gt;0.00006123&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00000040&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000,000&lt;/td&gt;
&lt;td&gt;0.01269281&lt;/td&gt;
&lt;td&gt;0.00870394&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00006129&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000,000&lt;/td&gt;
&lt;td&gt;1.32669707&lt;/td&gt;
&lt;td&gt;1.32506381&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.01232715&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Limited condition benchmark
&lt;/h1&gt;

&lt;p&gt;The following is sorted by the array [100,000,000].&lt;br&gt;
The unit is seconds, the lower the number, the faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worst case 1
&lt;/h2&gt;

&lt;p&gt;When changing the first to the maximum value for a sorted array.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Setsuna-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Msvc&lt;/td&gt;
&lt;td&gt;0.28328255&lt;/td&gt;
&lt;td&gt;1.27838705&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.03301556&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;clang++&lt;/td&gt;
&lt;td&gt;0.94680632&lt;/td&gt;
&lt;td&gt;1.49072315&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02450915&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g++&lt;/td&gt;
&lt;td&gt;1.24406811&lt;/td&gt;
&lt;td&gt;1.35104790&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02465655&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Worst case 2
&lt;/h2&gt;

&lt;p&gt;When changing the end to the minimum value for a sorted array.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Setsuna-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Msvc&lt;/td&gt;
&lt;td&gt;0.29024827&lt;/td&gt;
&lt;td&gt;1.27097092&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.03784692&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;clang++&lt;/td&gt;
&lt;td&gt;6.59369224&lt;/td&gt;
&lt;td&gt;1.44779880&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02844831&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g++&lt;/td&gt;
&lt;td&gt;7.05050788&lt;/td&gt;
&lt;td&gt;1.30785120&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.02579642&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Best case
&lt;/h2&gt;

&lt;p&gt;When the position is specified randomly without changing the value for the sorted array.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;std::sort&lt;/th&gt;
&lt;th&gt;std::stable_sort&lt;/th&gt;
&lt;th&gt;Setsuna-Shiki&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Msvc&lt;/td&gt;
&lt;td&gt;0.26143167&lt;/td&gt;
&lt;td&gt;1.24644350&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00000026&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;clang++&lt;/td&gt;
&lt;td&gt;0.99570890&lt;/td&gt;
&lt;td&gt;1.44735863&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00000031&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g++&lt;/td&gt;
&lt;td&gt;1.33114203&lt;/td&gt;
&lt;td&gt;1.30589223&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00000050&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  Finally
&lt;/h1&gt;

&lt;p&gt;How was it?&lt;/p&gt;

&lt;p&gt;We came up with the idea of ​​differential sorting, in terms of the fact that sorting does not always have to be done in its entirety.&lt;br&gt;
Although the comparison between std::sort and std::stable_sort, which is an overall sort, and Setsuna-Shiki, which is an diff sort, is not fair, it should be used to determine the usefulness of diff sort.&lt;/p&gt;

&lt;p&gt;If you operate well, you can get a rapid performance, but if you use it incorrectly it will be a two-edged sword.&lt;/p&gt;

&lt;p&gt;The sort algorithm is still romantic.&lt;/p&gt;

&lt;p&gt;Thanks for watching!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Introduction of new comparison stable sorting algorithm</title>
      <dc:creator>Emura Daisuke</dc:creator>
      <pubDate>Thu, 21 Mar 2019 06:40:15 +0000</pubDate>
      <link>https://dev.to/emuradaisuke/introduction-of-high-speed-comparison-stable-sorting-algorithm-hayate-shiki-9oe</link>
      <guid>https://dev.to/emuradaisuke/introduction-of-high-speed-comparison-stable-sorting-algorithm-hayate-shiki-9oe</guid>
      <description>&lt;h1&gt;
  
  
  颯式(Hayate-Shiki)
&lt;/h1&gt;

&lt;p&gt;It has the following features.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comparison sort&lt;/li&gt;
&lt;li&gt;Stable sort&lt;/li&gt;
&lt;li&gt;External area: N&lt;/li&gt;
&lt;li&gt;Best: O (N)&lt;/li&gt;
&lt;li&gt;Average: O (N log N)&lt;/li&gt;
&lt;li&gt;Worst: O (N log N)&lt;/li&gt;
&lt;li&gt;Recursion: None&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/EmuraDaisuke/SortingAlgorithm.HayateShiki"&gt;Hayate-Shiki(MIT License)&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic algorithm
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The external area is regarded as a 2N continuous band.&lt;/li&gt;
&lt;li&gt;The following rules apply when placing values ​​in the external area.

&lt;ul&gt;
&lt;li&gt;If (maximum &amp;lt;= value), place it above the ascending order column and update the maximum.&lt;/li&gt;
&lt;li&gt;If (value &amp;lt; minimum), place it below the descending column and update the minimum.&lt;/li&gt;
&lt;li&gt;If (minimum &amp;lt;= value &amp;lt; maximum), place new values ​​(maximum and minimum) in ascending order column, and let the value group arranged so far be Part.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Merge parts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The external area is regarded as a 2N continuous band.

4 5 1 2 7 6 3 8|Input column
. . . . . . . .|External area
-&amp;gt;Asc     Dsc&amp;lt;-|Actually

               |4 5 1 2 7 6 3 8|Input column
. . . . . . . . . . . . . . . .|External area
          Dsc&amp;lt;-|-&amp;gt;Asc          |2N continuous band
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Put new values ​​(maximum and minimum) in ascending order column.
               |. 5 1 2 7 6 3 8
. . . . . . . . 4 . . . . . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (maximum &amp;lt;= value), place it above the ascending order column and update the maximum.
               |. . 1 2 7 6 3 8
. . . . . . . . 4 5 . . . . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (value &amp;lt; minimum), place it below the descending column and update the minimum.
               |. . . 2 7 6 3 8
. . . . . . . 1 4 5 . . . . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (minimum &amp;lt;= value &amp;lt; maximum), place new values ​​(maximum and minimum) in ascending order column,
and let the value group arranged so far be Part.(Part: 145 completed)
               |. . . . 7 6 3 8
. . . . . . .|1 4 5|2 . . . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (maximum &amp;lt;= value), place it above the ascending order column and update the maximum.
               |. . . . . 6 3 8
. . . . . . .|1 4 5|2 7 . . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (minimum &amp;lt;= value &amp;lt; maximum), place new values ​​(maximum and minimum) in ascending order column,
and let the value group arranged so far be Part.(Part: 27 completed)
               |. . . . . . 3 8
. . . . . . .|1 4 5|2 7|6 . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (value &amp;lt; minimum), place it below the descending column and update the minimum.
               |. . . . . . . 8
. . . . . . 3|1 4 5|2 7|6 . . .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The next value is (maximum &amp;lt;= value), place it above the ascending order column and update the maximum.(Part: 368 completed)
               |. . . . . . . .
. . . . . .|3|1 4 5|2 7|6 8|. .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;External area result.
4 5|2 7|6 8|. .  Ascending column arrangement
. . . . . .|3|1  Descending column arrangement
4 5|2 7|6 8|3|1  Actual arrangement
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Merge generated Parts.
145  27  368
12457  368
12345678
Sort complete.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Improvement
&lt;/h1&gt;

&lt;p&gt;We will make additional improvements to the basic algorithm.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Insert sort is performed to secure the length of Part.&lt;/li&gt;
&lt;li&gt;Merge sequentially to avoid recursion.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Environment that we verified
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Windows 10 Pro 64bit&lt;/li&gt;
&lt;li&gt;Core i7-8700 3.20 GHz&lt;/li&gt;
&lt;li&gt;Microsoft(R) C/C++ Optimizing Compiler Version 19.16.27030.1 for x64&lt;/li&gt;
&lt;li&gt;clang version 8.0.0 (tags/RELEASE_800/final)&lt;/li&gt;
&lt;li&gt;gcc version 8.3.0 (Rev2, Built by MSYS2 project)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Random number benchmark
&lt;/h1&gt;

&lt;p&gt;Sorts float values ​​generated from the same seed.&lt;br&gt;
The unit is seconds, the lower the number, the faster.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aejuueRO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/4e82765c-2b15-9334-063c-6ca2e0894472.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aejuueRO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/4e82765c-2b15-9334-063c-6ca2e0894472.png" alt="Random_10000.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c2tA94cl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/530577cd-a21e-9d32-d801-3ca85a675cc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c2tA94cl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/530577cd-a21e-9d32-d801-3ca85a675cc5.png" alt="Random_1000000.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K-0leKyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/caed6f1f-1ff4-a798-66fc-187949451596.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K-0leKyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/caed6f1f-1ff4-a798-66fc-187949451596.png" alt="Random_100000000.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conditional benchmark
&lt;/h1&gt;

&lt;p&gt;The following all sorted the array [100,000,000] of float value.&lt;br&gt;
The unit is seconds, the lower the number, the faster.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tqiI8gdg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/8af35731-e0e7-f346-792c-f3944345c82f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tqiI8gdg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/8af35731-e0e7-f346-792c-f3944345c82f.png" alt="Msvc.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o1tw0n3M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/16872a88-51ec-00d0-31eb-44f0994cd23c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o1tw0n3M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/16872a88-51ec-00d0-31eb-44f0994cd23c.png" alt="clang++.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mUlWRRxP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/bbca437a-7977-e03f-159a-db5977506f79.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mUlWRRxP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/379361/bbca437a-7977-e03f-159a-db5977506f79.png" alt="g++.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Finally
&lt;/h1&gt;

&lt;p&gt;How was it?  &lt;/p&gt;

&lt;p&gt;Hayate-Shiki is a stable sort, but has strong characteristics to random numbers.&lt;br&gt;
In the conditional benchmark, it was found that the influence of the optimization characteristic of the compiler, rather than the algorithm characteristic, becomes strong, so that it can hardly be a judgment material.&lt;/p&gt;

&lt;p&gt;Does it come the day when merge sort wins quick sort?  &lt;/p&gt;

&lt;p&gt;The sort algorithm is still romantic.  &lt;/p&gt;

&lt;p&gt;Thanks for watching!&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
