5
A
回答
0
0
這是維基百科:Worst-case analysis of data structures
+----------------------+----------+------------+----------+--------------+
| | Insert | Delete | Search | Space Usage |
+----------------------+----------+------------+----------+--------------+
| Unsorted array | O(1) | O(1) | O(n) | O(n) |
| Value-indexed array | O(1) | O(1) | O(1) | O(n) |
| Sorted array | O(n) | O(n) | O(log n) | O(n) |
| Unsorted linked list | O(1)* | O(1)* | O(n) | O(n) |
| Sorted linked list | O(n)* | O(1)* | O(n) | O(n) |
| Balanced binary tree | O(log n) | O(log n) | O(log n) | O(n) |
| Heap | O(log n) | O(log n)** | O(n) | O(n) |
| Hash table | O(1) | O(1) | O(1) | O(n) |
+----------------------+----------+------------+----------+--------------+
* The cost to add or delete an element into a known location in the list
(i.e. if you have an iterator to the location) is O(1).
If you don't know the location, then you need to traverse the list to the location of deletion/insertion, which takes O(n) time.
** The deletion cost is O(log n) for the minimum or maximum, O(n) for an arbitrary element.
相關問題
- 1. 複製數據結構和空間複雜性
- 2. MongoDB:構建複雜的數據結構
- 3. Rtti訪問複雜數據結構中的字段和屬性
- 4. Python數據結構的複雜性/性能檢查
- 5. 隱藏複雜的微數據結構
- 6. numpy複雜的數據結構
- 7. Java中的複雜數據結構
- 8. 複雜的數據結構Redis
- 9. 根據Big-O表示法對不同數據結構進行不同操作的複雜性
- 10. 結構複雜
- 11. 數據結構之間的複雜性比較
- 12. MySQL:複雜的數據結構化和查詢
- 13. 遷移和備份模式(複雜的數據庫結構)
- 14. pycparser.plyparser.ParseError複雜結構
- 15. AutoMapping複雜結構
- 16. 在Python中構建「複雜」數據結構的最佳方式
- 17. 使用GraphQL結構來構建複雜的數據庫查詢
- 18. Struts2的 - 從結構複雜
- 19. 複雜的graphviz樹結構
- 20. 複雜結構的詞幹
- 21. 複雜的TreeView結構 - HierarchicalDataTemplate
- 22. XSD複雜的XML結構
- 23. Lucene複雜結構搜索
- 24. Matlab:查詢複雜結構
- 25. firebase檢索複雜結構
- 26. 測試複雜結構
- 27. 複製複雜的字典結構
- 28. Cassandra:複雜的嵌套JSON數據的表結構
- 29. 對ios上的複雜數據結構的sqlite或coredata
- 30. MVVM的ViewModel層中的複雜數據結構
這正是我想避免。但誰知道它可能很有趣。不管怎麼說,還是要謝謝你。 – 2011-01-06 13:58:11