All Projects → EmuraDaisuke → Sortingalgorithm.hayateshiki

EmuraDaisuke / Sortingalgorithm.hayateshiki

Licence: mit
Hayate-Shiki is an improved merge sort algorithm with the goal of "faster than quick sort".

Projects that are alternatives of or similar to Sortingalgorithm.hayateshiki

C Plus Plus
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Stars: ✭ 17,151 (+20317.86%)
Mutual labels:  algorithm, computer-science, sort
Quadsort
Quadsort is a stable adaptive merge sort which is faster than quicksort.
Stars: ✭ 1,385 (+1548.81%)
Mutual labels:  algorithm, sort, sorting
.codebits
📚 List of resources for Algorithms and Data Structures in Python & other CS topics @2017
Stars: ✭ 144 (+71.43%)
Mutual labels:  algorithm, computer-science, programming
Data Science Masters
Self-study plan to achieve mastery in data science
Stars: ✭ 179 (+113.1%)
Mutual labels:  algorithm, computer-science, data-science
Cpp Timsort
A C++ implementation of timsort
Stars: ✭ 211 (+151.19%)
Mutual labels:  algorithm, sort, sorting
Learn Something Every Day
📝 A compilation of everything that I learn; Computer Science, Software Development, Engineering, Math, and Coding in General. Read the rendered results here ->
Stars: ✭ 362 (+330.95%)
Mutual labels:  algorithm, computer-science, data-science
Cs Books
📚 Computer Science Books 计算机技术类书籍 PDF
Stars: ✭ 2,915 (+3370.24%)
Mutual labels:  algorithm, computer-science, programming
Teaching
Teaching Materials for Dr. Waleed A. Yousef
Stars: ✭ 435 (+417.86%)
Mutual labels:  computer-science, data-science, programming
Dsa.js Data Structures Algorithms Javascript
🥞Data Structures and Algorithms explained and implemented in JavaScript + eBook
Stars: ✭ 6,251 (+7341.67%)
Mutual labels:  algorithm, computer-science
Tech Refrigerator
🍰 기술 냉장고입니다. 🛒 기술 면접 , 전공 시험 , 지식 함양 등 분명 도움될 거예요! 🤟
Stars: ✭ 699 (+732.14%)
Mutual labels:  algorithm, computer-science
Model Describer
model-describer : Making machine learning interpretable to humans
Stars: ✭ 22 (-73.81%)
Mutual labels:  algorithm, data-science
P1xt Guides
Programming curricula
Stars: ✭ 6,054 (+7107.14%)
Mutual labels:  computer-science, programming
Learningmasteringalgorithms C
Mastering Algorithms with C 《算法精解:C语言描述》源码及Xcode工程、Linux工程
Stars: ✭ 615 (+632.14%)
Mutual labels:  algorithm, sort
Table Dragger
Turn your old table to drag-and-drop table with columns and rows sorting like magic!
Stars: ✭ 704 (+738.1%)
Mutual labels:  sort, sorting
Kotlin Algorithm Club
Algorithms and data structures in Kotlin.
Stars: ✭ 576 (+585.71%)
Mutual labels:  algorithm, computer-science
Awesome Scalability
The Patterns of Scalable, Reliable, and Performant Large-Scale Systems
Stars: ✭ 36,688 (+43576.19%)
Mutual labels:  computer-science, programming
Machine Learning Open Source
Monthly Series - Machine Learning Top 10 Open Source Projects
Stars: ✭ 943 (+1022.62%)
Mutual labels:  algorithm, data-science
Interactive Coding Challenges
120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.
Stars: ✭ 24,317 (+28848.81%)
Mutual labels:  algorithm, programming
Papers We Love Bbsr
Papers-we-love bhubaneswar chapter
Stars: ✭ 12 (-85.71%)
Mutual labels:  computer-science, programming
Constant Vigilance
Learn this if you want to be a software engineer. Constant vigilance means being continually aware of areas that need improvement. For me, I am constantly searching for valuable resources to ensure I am able to solve any problem that comes my way.
Stars: ✭ 30 (-64.29%)
Mutual labels:  algorithm, computer-science

颯式(Hayate-Shiki)

Hayate-Shiki is an improved merge sort algorithm with the goal of "faster than quick sort".

It has the following features.

  • Comparison sort
  • Stable sort
  • External area: N
  • Best: O (N)
  • Average: O (N log N)
  • Worst: O (N log N)
  • Recursion: None

Basic algorithm

  • The external area is regarded as a 2N continuous band.
  • The following rules apply when placing values ​​in the external area.
    • If (maximum <= value), place it above the ascending order column and update the maximum.
    • If (value < minimum), place it below the descending column and update the minimum.
    • If (minimum <= value < maximum), place new values ​​(maximum and minimum) in ascending order column, and let the value group arranged so far be Part.
  • Merge parts.

Examples

The external area is regarded as a 2N continuous band.

4 5 1 2 7 6 3 8|Input column
. . . . . . . .|External area
->Asc     Dsc<-|Actually

               |4 5 1 2 7 6 3 8|Input column
. . . . . . . . . . . . . . . .|External area
          Dsc<-|->Asc          |2N continuous band
Put new values ​​(maximum and minimum) in ascending order column.
               |. 5 1 2 7 6 3 8
. . . . . . . . 4 . . . . . . .
The next value is (maximum <= value), place it above the ascending order column and update the maximum.
               |. . 1 2 7 6 3 8
. . . . . . . . 4 5 . . . . . .
The next value is (value < minimum), place it below the descending column and update the minimum.
               |. . . 2 7 6 3 8
. . . . . . . 1 4 5 . . . . . .
The next value is (minimum <= value < 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 . . . . .
The next value is (maximum <= value), place it above the ascending order column and update the maximum.
               |. . . . . 6 3 8
. . . . . . .|1 4 5|2 7 . . . .
The next value is (minimum <= value < 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 . . .
The next value is (value < minimum), place it below the descending column and update the minimum.
               |. . . . . . . 8
. . . . . . 3|1 4 5|2 7|6 . . .
The next value is (maximum <= value), place it above the ascending order column and update the maximum.(Part: 368 completed)
               |. . . . . . . .
. . . . . .|3|1 4 5|2 7|6 8|. .
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
Merge generated Parts.
145  27  368
12457  368
12345678
Sort complete.

Improvement

We will make additional improvements to the basic algorithm.

  • Insert sort is performed to secure the length of Part.
  • Merge sequentially to avoid recursion.

Build & Test

The following environment has been verified.

  • Windows 10 Pro 64bit
  • Core i7-8700 3.20 GHz

Msvc

Microsoft(R) C/C++ Optimizing Compiler Version 19.16.27030.1 for x64

cl Main.cpp -std:c++14 -Ox -EHsc -Fe:TestMsvc.exe
TestMsvc.exe

clang++

clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-w64-windows-gnu

clang++ Main.cpp -std=c++14 -O3 -o TestClang++.exe
TestClang++.exe

g++

gcc version 8.3.0 (Rev2, Built by MSYS2 project)
Target: x86_64-w64-mingw32

g++ Main.cpp -std=c++14 -O3 -o TestG++.exe
TestG++.exe

Random number benchmark

Sorts float values ​​generated from the same seed.
The unit is seconds, the lower the number, the faster.

Random_10000 Random_1000000 Random_100000000


Conditional benchmark

The following all sorted the array [100,000,000] of float value.
The unit is seconds, the lower the number, the faster.

Msvc clang++ g++


Finally

How was it?

Hayate-Shiki is a stable sort, but has strong characteristics to random numbers.
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.

Does it come the day when merge sort wins quick sort?

The sort algorithm is still romantic.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].