軟糖曾經有過研究,如下:
public?void?時間復雜度平均()
{
Dictionary<int,?object>?字典;?//字典是最快的
訪問.O(1);?搜索.O(1);?插入.O(1);?刪除.O(1);
Hashtable?哈希表;?HashSet<int>?哈希集;
訪問.O(null);?搜索.O(1);?插入.O(1);?刪除.O(1);
SortedList<int,?object>?有序列表;
訪問.O(1);?搜索.O(Log(n));?插入.O(Log(n));?刪除.O(n);
SortedDictionary<int,?object>?有序字典;
訪問.O(1);?搜索.O(Log(n));?插入.O(Log(n));?刪除.O(Log(n));
Queue?隊列;?Stack?堆棧;?LinkedList<int>?雙向鏈表;
訪問.O(n);?搜索.O(n);?插入.O(1);?刪除.O(1);
Array?數組;?List<int>?列表;
訪問.O(1);?搜索.O(n);?插入.O(n);?刪除.O(n);
SortedSet<int>?有序集;?//二叉樹
訪問.O(Log(n));?搜索.O(Log(n));?插入.O(Log(n));?刪除.O(Log(n));
}
從網上數據結構資料搜集而來,並沒有實際測試,如有不符請指出。
如滿意,請采納,謝謝。