## 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 最牛的超级算法集.zip
共344个文件
rs:320个
md:9个
yml:6个
需积分: 5 0 下载量 118 浏览量
2024-05-15
14:20:18
上传
评论
收藏 398KB ZIP 举报
温馨提示
Rust 是一种系统编程语言,它旨在提供内存安全性和并发安全性的同时,保持高性能和低级访问能力。Rust 的主要特性包括:12 内存安全:Rust 提供了内存安全保障,通过其独特的所有权系统和借用规则来避免常见的内存错误和安全漏洞。 并发模型:Rust 提供了强大的并发模型,使得开发者能够轻松地编写高效的多线程代码。 类型系统:Rust 的类型系统支持类似类型类的机制“traits”,用于特定同质性的设施,通过给类型变量声明添加约束来实现。 所有权系统:Rust 拥有一个所有权系统,所有的值都有一个唯一的属主,值的有效范围跟属主的有效范围一样。 生命周期:Rust 通过 RAII(Resource Acquisition Is Initialization)来管理内存和资源,不使用自动垃圾回收系统。 工具和生态系统:Rust 拥有一个强大且规范的生态系统,包括丰富的工具和库。 Rust 的学习曲线可能有些陡峭,但它的设计哲学和特性使其成为系统编程领域的热门选择。它适合对性能要求高的关键服务,如嵌入式设备,并且可以与其他语言集成。
资源推荐
资源详情
资源评论
收起资源包目录
Rust 最牛的超级算法集.zip (344个子文件)
CODEOWNERS 18B
.gitpod.Dockerfile 163B
.gitconfig 33B
.gitignore 67B
LICENSE 1KB
DIRECTORY.md 31KB
README.md 16KB
README.md 4KB
README.md 4KB
README.md 4KB
README.md 3KB
README.md 2KB
pull_request_template.md 1KB
CONTRIBUTING.md 866B
pre-commit 21B
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 10KB
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
decremental_connectivity.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
levenshtein_distance.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
knight_tour.rs 6KB
graph.rs 6KB
b_tree.rs 6KB
chacha.rs 6KB
prim.rs 6KB
eulerian_path.rs 5KB
centroid_decomposition.rs 5KB
merge_sort.rs 5KB
heap.rs 5KB
dijkstra.rs 5KB
knapsack.rs 5KB
tim_sort.rs 5KB
naive.rs 5KB
strongly_connected_components.rs 5KB
breadth_first_search.rs 5KB
convex_hull.rs 5KB
depth_first_search.rs 5KB
salsa.rs 5KB
sudoku.rs 5KB
topological_sort.rs 4KB
greatest_common_divisor.rs 4KB
range_minimum_query.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
lib.rs 4KB
average.rs 4KB
linear_sieve.rs 4KB
prufer_code.rs 4KB
bell_numbers.rs 4KB
共 344 条
- 1
- 2
- 3
- 4
资源评论
野生的狒狒
- 粉丝: 2629
- 资源: 2167
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SNMP Client 是SNMP测试工具
- AD9220高速数据芯片硬件参考设计原理图+STM32F103单片机驱动程序代码+芯片技术手册资料.zip
- 常用爆破用户名字典top500
- meta-llama-3-8b-instruct 的 model-00003-of-00004.safetensors 的2/3
- bootstrap-select.js bootstrap-select.css
- EasyPoi Excel和 Word简易工具类
- 华为实验一 MPI 矩阵运算
- 网卡MAC地址修改工具 HardDiskSNC HWID changer 等电脑信息修改工具小软件合集(8个).zip
- 华为实验一 MPI 矩阵运算
- mysql语句大全及用法简介及基础教程及特点阐述.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功