常用数据结构的时间复杂度

常用数据结构的时间复杂度

数据结构

添加

查找

删除

获取索引值

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)

-

猜你喜欢

转载自blog.csdn.net/qq_29373285/article/details/84967532