标签:style blog http io 使用 ar strong 数据 cti
程序的复杂度分为时间复杂度和空间复杂度,通过字面上可以看出它们的含义,下面我们主要来看一个集合的时间复杂度,这些集合基本包含了.net里的所有了,呵呵!
Data Structure | Add | Find | Delete | GetByIndex |
Array (T[]) |
O(n) |
O(n) |
O(n) |
O(1) |
Linked list (LinkedList<T>) |
O(1) |
O(n) |
O(n) |
O(n) |
Resizable array list (List<T>) |
O(1) |
O(n) |
O(n) |
O(1) |
Stack (Stack<T>) |
O(1) |
- |
O(1) |
- |
Queue (Queue<T>) |
O(1) |
- |
O(1) |
- |
Hash table (Dictionary<K,T>) |
O(1) |
O(1) |
O(1) |
- |
Tree-based dictionary (SortedDictionary<K,T>) |
O(log n) |
O(log n) |
O(log n) |
- |
Hash table based set (HashSet<T>) |
O(1) |
O(1) |
O(1) |
- |
Tree based set (SortedSet<T>) |
O(log n) |
O(log n) |
O(log n) |
- |
Array (T[])
Linked list (LinkedList<T>)
Resizable array list (List<T>)
Stack (Stack<T>)
Queue (Queue<T>)
Hash table (Dictionary<K,T>)
Tree-based dictionary (SortedDictionary<K,T>)
Hash table based set (HashSet<T>)
Tree based set (SortedSet<T>)
本文原文由Dennis Gao 发表自博客园,本人只是收藏之
本文章来自:http://www.cnblogs.com/gaochundong/p/3813252.html
相关参考资料:
标签:style blog http io 使用 ar strong 数据 cti
原文地址:http://www.cnblogs.com/lori/p/3962707.html