## Sort Algorithms
### [Bogo-sort](./bogo_sort.rs)
![alt text][bogo-image]
From [Wikipedia][bogo-wiki]: In computer science, bogosort is a sorting algorithm based on the generate and test paradigm. The function successively generates permutations of its input until it finds one that is sorted. It is not considered useful for sorting, but may be used for educational purposes, to contrast it with more efficient algorithms.
__Properties__
* Worst case performance (unbounded in randomized version)
* Best case performance O(n)
* Average case performance O((n+1)!)
### [Bubble](./bubble_sort.rs)
![alt text][bubble-image]
From [Wikipedia][bubble-wiki]: Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n)
* Average case performance O(n^2)
###### View the algorithm in [action][bubble-toptal]
### [Cocktail-Shaker](./cocktail_shaker_sort.rs)
![alt text][shaker-image]
From [Wikipedia][shaker-wiki]: Cocktail shaker sort, also known as bidirectional bubble sort, cocktail sort, shaker sort (which can also refer to a variant of selection sort), ripple sort, shuffle sort, or shuttle sort, is an extension of bubble sort. The algorithm extends bubble sort by operating in two directions. While it improves on bubble sort by more quickly moving items to the beginning of the list, it provides only marginal performance improvements.
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n)
* Average case performance O(n^2)
### [Comb-sort](./comb_sort.rs)
![comb sort][comb-sort]
From [wikipedia][comb-sort-wiki]: Comb sort is a relatively simple sorting algorithm and improves on bubble sort in the same way that shell sort improves on insertion sort. The basic idea of comb sort is that the gap(distance from two compared elements) can be much more than 1. And the inner loop of bubble sort, which does actual `swap`, is modified such that the gap between swapped elements goes down in steps of a `shrink factor k: [n/k, n/k^2, ..., 1]`. And the gap is divided by the shrink factor in every loop, and the process repeats until the gap is 1. At this point, comb sort continues using a gap of 1 until the list is fully sorted. The final stage of the sort is thus equivalent to a bubble sort, but this time most turtles have been dealt with, so a bubble sort will be efficient. And the shrink factor has a great effect on the efficiency of comb sort and `k=1.3` has been suggested as an ideal value.
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n log n)
* Average case performance O(n^2/2^p)
where `p` is the number of increments.
### [Counting](./counting_sort.rs)
From [Wikipedia][counting-wiki]: In computer science, counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct key value, and using arithmetic on those counts to determine the positions of each key value in the output sequence. Its running time is linear in the number of items and the difference between the maximum and minimum key values, so it is only suitable for direct use in situations where the variation in keys is not significantly greater than the number of items. However, it is often used as a subroutine in another sorting algorithm, radix sort, that can handle larger keys more efficiently.
__Properties__
* Worst case performance O(n+k)
* Best case performance O(n+k)
* Average case performance O(n+k),
where n is the number of integers to sort and k is the difference between the largest and smallest integer in our list.
### [Insertion](./insertion_sort.rs)
![alt text][insertion-image]
From [Wikipedia][insertion-wiki]: Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n)
* Average case performance O(n^2)
###### View the algorithm in [action][insertion-toptal]
### [Gnome](./gnome_sort.rs)
![alt text][gnome-image]
From [Wikipedia][gnome-wiki]: The gnome sort is a sorting algorithm which is similar to insertion sort in that it works with one item at a time but gets the item to the proper place by a series of swaps, similar to a bubble sort. It is conceptually simple, requiring no nested loops. The average running time is O(n^2) but tends towards O(n) if the list is initially almost sorted
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n)
* Average case performance O(n^2)
### [Merge](./merge_sort.rs)
![alt text][merge-image]
From [Wikipedia][merge-wiki]: In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945.
__Properties__
* Worst case performance O(n log n)
* Best case performance O(n log n)
* Average case performance O(n log n)
###### View the algorithm in [action][merge-toptal]
### [Odd-even](./odd_even_sort.rs)
![alt text][odd-even-image]
From [Wikipedia][odd-even-wiki]: In computing, an odd–even sort or odd–even transposition sort (also known as brick sort or parity sort) is a relatively simple sorting algorithm, developed originally for use on parallel processors with local interconnections. It is a comparison sort related to bubble sort, with which it shares many characteristics. It functions by comparing all odd/even indexed pairs of adjacent elements in the list and, if a pair is in the wrong order (the first is larger than the second) the elements are switched. The next step repeats this for even/odd indexed pairs (of adjacent elements). Then it alternates between odd/even and even/odd steps until the list is sorted.
NOTE: The implementation is an adaptation of the algorithm for a single-processor machine, while the original algorithm was devised to be executed on many processors simultaneously.
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n)
* Average case performance O(n^2)
### [Pancake](./pancake_sort.rs)
![alt text][pancake-image]
From [Wikipedia][pancake-wiki]: All sorting methods require pairs of elements to be compared. For the traditional sorting problem, the usual problem studied is to minimize the number of comparisons required to sort a list. The number of actual operations, such as swapping two elements, is then irrelevant. For pancake sorting problems, in contrast, the aim is to minimize the number of operations, where the only allowed operations are reversals of the elements of some prefix of the sequence. Now, the number of comparisons is irrelevant.
### [Quick](./quick_sort.rs)
![alt text][quick-image]
From [Wikipedia][quick-wiki]: Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order.
__Properties__
* Worst case performance O(n^2)
* Best case performance O(n log n) or O(n) with three-way partition
* Average case performance O(n log n)
###### View the algorithm in [action][quick-toptal]
### [Radix](./radix_sort.rs)
![alt text][radix-image]
From [Wikipedia][radix-wiki]: Radix sort is a non-comparative sorting algorithm. It avoids comparison by creating and distributing elements i
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于Rust 算法集合2024 (323个子文件)
.gitpod.Dockerfile 163B
DIRECTORY.md 30KB
README.md 16KB
README.md 4KB
README.md 4KB
README.md 4KB
README.md 3KB
README.md 2KB
CONTRIBUTING.md 866B
aes.rs 27KB
sha3.rs 22KB
rb_tree.rs 19KB
genetic.rs 17KB
fibonacci.rs 15KB
linked_list.rs 15KB
diffie_hellman.rs 15KB
matrix_ops.rs 13KB
depth_first_search_tic_tac_toe.rs 13KB
elliptic_curve.rs 12KB
sha256.rs 11KB
bloom_filter.rs 11KB
lazy_segment_tree.rs 11KB
binary_search_tree.rs 11KB
avl_tree.rs 10KB
veb_tree.rs 10KB
blake2b.rs 10KB
count_min_sketch.rs 10KB
adam.rs 10KB
treap.rs 9KB
base64.rs 9KB
bellman_ford.rs 9KB
transposition.rs 9KB
pollard_rho.rs 9KB
miller_rabin.rs 9KB
field.rs 8KB
trig_functions.rs 8KB
astar.rs 8KB
bipartite_matching.rs 8KB
quadratic_residue.rs 8KB
segment_tree_recursive.rs 8KB
segment_tree.rs 7KB
stack_using_singly_linked_list.rs 7KB
lowest_common_ancestor.rs 7KB
huffman_encoding.rs 7KB
union_find.rs 7KB
graham_scan.rs 7KB
closest_points.rs 7KB
kmeans.rs 7KB
fast_fourier_transform.rs 6KB
segment.rs 6KB
mod.rs 6KB
floyd_warshall.rs 6KB
heavy_light_decomposition.rs 6KB
dinic_maxflow.rs 6KB
morse_code.rs 6KB
jarvis_scan.rs 6KB
graph.rs 6KB
b_tree.rs 6KB
chacha.rs 6KB
prim.rs 6KB
levenshtein_distance.rs 6KB
eulerian_path.rs 5KB
centroid_decomposition.rs 5KB
merge_sort.rs 5KB
heap.rs 5KB
dijkstra.rs 5KB
knapsack.rs 5KB
strongly_connected_components.rs 5KB
breadth_first_search.rs 5KB
convex_hull.rs 5KB
depth_first_search.rs 5KB
naive.rs 5KB
salsa.rs 5KB
sudoku.rs 5KB
topological_sort.rs 4KB
greatest_common_divisor.rs 4KB
binary_search_recursive.rs 4KB
suffix_tree.rs 4KB
tarjans_ssc.rs 4KB
random.rs 4KB
kosaraju.rs 4KB
modular_exponential.rs 4KB
aho_corasick.rs 4KB
ford_fulkerson.rs 4KB
quick_sort_3_ways.rs 4KB
average.rs 4KB
linear_sieve.rs 4KB
prufer_code.rs 4KB
heap_sort.rs 4KB
bell_numbers.rs 4KB
minimum_spanning_tree.rs 4KB
snail.rs 4KB
tea.rs 4KB
simpsons_integration.rs 4KB
two_satisfiability.rs 4KB
polybius.rs 4KB
hash_table.rs 4KB
manacher.rs 4KB
lee_breadth_first_search.rs 3KB
mod.rs 3KB
共 323 条
- 1
- 2
- 3
- 4
资源评论
pangjiaqian
- 粉丝: 220
- 资源: 184
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功