假设我有大小为 N 的数据(即 N 个元素),并且字典是用容量 N 创建的。 的复杂性是什么:
MS 仅显示条目检索接近 O(1)。但是剩下的呢?
最佳答案
添加新条目的时间复杂度记录在 Dictionary<T>.Add()
下:
If Count is less than the capacity, this method approaches an O(1) operation. If the capacity must be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.
关于c# - Dictionary 的时间和空间复杂度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19584938/