Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sorting algorithms implemented in Rust

License

NotificationsYou must be signed in to change notification settings

flakusha/sorting_rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorting algorithms implemented in Rust.

Usage

  1. Add this dependency and please consider it's version into your Cargo.toml:
[dependencies]sorting_rs ="1.2.0"
  1. Use available sorting algorithms in your Rust code:
use sorting_rs::*;
  1. API for every sorting function is pretty the same: you just have to passmutable reference:&mut [T], orvec![T, T, T, ...].T should havePartialOrd trait, sometimes you may needCopy orClone traits, thoughall implementations try to avoid this kind of additional requirements.
  2. For more information about origin of algorithms and implementation details,please read modules documentation.Wikipedia is nice startingpoint too.

This library contains following sorting algorithms:

Sorting algorithmFeatures and downsidesWorst-case performance O(): comparisons; swapsBest-case performance O(): comparisons; swapsSpace complexity O()
Bingoaims to be faster than selection sort if there are duplicatesn + m2nm
Bitonicmethod based on building a sorting networknlog2nnlog2nnlog2n
Bubblebad for sorted or reversed inputn2;n2n;11
Cocktaillittle performance improvement over bubble sortn2n1
Combspeeds up when data is nearly sortedn2nlogn1
Cycleuses minimum amount of writes, good for memory with limited TBWn2n21
Gnomesimple and slow, works with one item at a timen2n1
Heapindependent of data distributionnlognnlogn1
Weak Heapindependent of data distribution, decreased number of comparisonsnlognnlogn1
N-Heapshould be faster than default heap. N = 3nlognnlogn1
Bottom-up Heapupgraded version of heapsort with decreased number of comparisonsnlognnlogn1
Insertionsimple, but less effective than quicksort, heapsort or merge sortn2;n2n;11
Mergeindependent of data distributionnlognnlognn
Merge Bottom-upindependent of data distribution, modified version of mergesortnlognnlognn
Odd-evenpresented to be effective on processors with local interconnectionsn2n1
Odd-even Batchermore efficient version of odd-even sortlog2nlog2nlogn2
Pancakeswaps data a lot and not so effective in practicen3;2n - 3n2n
Quickbad for sorted or reversed inputn2nlognlogn
Quick dualenchanced version of quicksortn22nlnnlogn
Ksortquicksort variant, faster than heap at less than 7 million elementsn2nlog2nlogn
Selectionthe least number of swaps among all the algorithmsn2;nn2;11
Double selectionmodified selection sort with more workload, but better efficiencyn2;nn2;1higher than Selection
Shellsortit is optimization of insertion sortn3/2 ornlogn2nlogn1
Slowit's slow, who would ever need it?
Smoothvariant of heapsort, good for nearly sorted datanlognn1
Stoogeit's a bit faster than slow sortn2.7095n

New algorithms implementations are planned in future

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp