算法复杂度总结!
来源:互联网 发布:avmask永久域名 编辑:程序博客网 时间:2024/06/05 01:03
刚看到一个很好的算法复杂度总结的贴,果断转了。
原文链接:http://bigocheatsheet.com/#
坑爹,那些表格没法完全显示,大家可以点上面的链接看原文。
Searching
Algorithm Data Structure Time Complexity Space Complexity Average Worst Worst
-
O(|E| + |V|)
O(|V|)
Breadth First Search (BFS)Graph of |V| vertices and |E| edges-
O(|E| + |V|)
O(|V|)
Binary searchSorted array of n elementsO(log(n))
O(log(n))
O(1)
Linear (Brute Force)ArrayO(n)
O(n)
O(1)
Shortest path by Dijkstra,using a Min-heap as priority queueGraph with |V| vertices and |E| edges
O((|V| + |E|) log |V|)
O((|V| + |E|) log |V|)
O(|V|)
Shortest path by Dijkstra,using an unsorted array as priority queueGraph with |V| vertices and |E| edges
O(|V|^2)
O(|V|^2)
O(|V|)
Shortest path by Bellman-FordGraph with |V| vertices and |E| edgesO(|V||E|)
O(|V||E|)
O(|V|)
Sorting
O(n log(n))
O(n log(n))
O(n^2)
O(n)
MergesortArrayO(n log(n))
O(n log(n))
O(n log(n))
O(n)
HeapsortArrayO(n log(n))
O(n log(n))
O(n log(n))
O(1)
Bubble SortArrayO(n)
O(n^2)
O(n^2)
O(1)
Insertion SortArrayO(n)
O(n^2)
O(n^2)
O(1)
Select SortArrayO(n^2)
O(n^2)
O(n^2)
O(1)
Bucket SortArrayO(n+k)
O(n+k)
O(n^2)
O(nk)
Radix SortArrayO(nk)
O(nk)
O(nk)
O(n+k)
Data Structures
O(1)
O(n)
-
-
O(1)
O(n)
-
-
O(n)
Dynamic ArrayO(1)
O(n)
O(n)
O(n)
O(1)
O(n)
O(n)
O(n)
O(n)
Singly-Linked ListO(n)
O(n)
O(1)
O(1)
O(n)
O(n)
O(1)
O(1)
O(n)
Doubly-Linked ListO(n)
O(n)
O(1)
O(1)
O(n)
O(n)
O(1)
O(1)
O(n)
Skip ListO(log(n))
O(log(n))
O(log(n))
O(log(n))
O(n)
O(n)
O(n)
O(n)
O(n log(n))
Hash Table-
O(1)
O(1)
O(1)
-
O(n)
O(n)
O(n)
O(n)
Binary Search TreeO(log(n))
O(log(n))
O(log(n))
O(log(n))
O(n)
O(n)
O(n)
O(n)
O(n)
Cartresian Tree-
O(log(n))
O(log(n))
O(log(n))
-
O(n)
O(n)
O(n)
O(n)
B-TreeO(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(n)
Red-Black TreeO(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(n)
Splay Tree-
O(log(n))
O(log(n))
O(log(n))
-
O(log(n))
O(log(n))
O(log(n))
O(n)
AVL TreeO(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(n)
Heaps
-
O(1)
O(1)
O(n)
O(n)
O(1)
O(m+n)
Linked List (unsorted)-
O(n)
O(n)
O(1)
O(1)
O(1)
O(1)
Binary HeapO(n)
O(1)
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(m+n)
Binomial Heap-
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
O(log(n))
Fibonacci Heap-
O(1)
O(log(n))*
O(1)*
O(1)
O(log(n))*
O(1)
Graphs
O(|V|+|E|)
O(1)
O(1)
O(|V| + |E|)
O(|E|)
O(|V|)
Incidence listO(|V|+|E|)
O(1)
O(1)
O(|E|)
O(|E|)
O(|E|)
Adjacency matrixO(|V|^2)
O(|V|^2)
O(1)
O(|V|^2)
O(1)
O(1)
Incidence matrixO(|V| ⋅ |E|)
O(|V| ⋅ |E|)
O(|V| ⋅ |E|)
O(|V| ⋅ |E|)
O(|V| ⋅ |E|)
O(|E|)
Notation for asymptotic growth
[1] Big O is the upper bound, while Omega is the lower bound. Theta requires both Big O and Omega, so that's why it's referred to as a tight bound (it must be both the upper and lower bound). For example, an algorithm taking Omega(n log n) takes at least n log n time but has no upper limit. An algorithm taking Theta(n log n) is far preferential since it takes AT LEAST n log n (Omega n log n) and NO MORE THAN n log n (Big O n log n).SO
[2] f(x)=Θ(g(n)) means f (the running time of the algorithm) grows exactly like g when n (input size) gets larger. In other words, the growth rate of f(x) is asymptotically proportional to g(n).
[3] Same thing. Here the growth rate is no faster than g(n). big-oh is the most useful because represents the worst-case behavior.
In short, if algorithm is __ then its performance is __Contribute
Edit these tables!Authors:
- Eric Rowell
- Quentin Pleple
- Nick Dizazzo
- Michael Abed
- Adam Forsyth
- Jay Engineer
- Josh Davis
- makosblade
- Alejandro Ramirez
- Joel Friedly
- Robert Burke
- David Dorfman
- Eric Lefevre-Ardant
- Thomas Dybdahl Ahle
- 算法复杂度总结
- 算法复杂度总结!
- 算法复杂度总结
- 算法复杂度总结表
- 算法复杂度总结
- 算法复杂度总结
- 算法时间复杂度和空间复杂度总结
- 常用算法和复杂度总结
- 排序算法_复杂度总结
- 一些常见算法复杂度总结
- 排序算法时间复杂度总结
- 面试用算法复杂度总结
- 算法的时间复杂度和空间复杂度-总结
- 【算法的时间复杂度和空间复杂度-总结】
- 算法的时间复杂度和空间复杂度-总结
- 算法的时间复杂度和空间复杂度-总结
- 算法的时间复杂度和空间复杂度-总结
- 算法的时间复杂度和空间复杂度-总结
- Android教程视频汇总
- Response.Redirect ,Server.Transfer ,Server.Execute, 的区别(比较)
- iOS学习--NSCalendar
- Linux Shell 通配符、元字符、转义符使用实例介绍
- Ubuntu 12.10安装google chrome浏览器
- 算法复杂度总结!
- 多线程内存池实现代码-双链表
- HDU——3602 2012
- oracle 隨機取數據
- struts 表单乱码
- C#常用文件操作
- 使用spring配置RMI
- Android资源目录---assets与res/raw区别
- jsp之监听器