【发布时间】:2015-01-22 10:08:46
【问题描述】:
我需要获得缓存复杂度 O(log (n))。据说这种复杂性允许映射和列表。比如实现:
http://blackcat.ca/svn/trunk/lru_cache/src/lru_cache.h
但是在这个算法中,列表中存在这样的操作: List.splice() - 复杂度 O(n)。 List.erase() - 复杂度 O(n)。
这里人们说map和list的复杂度是O(log(n))。 https://stackoverflow.com/a/3640392/3274299
为什么是 O(log(n))?必须有 O(n)。
【问题讨论】:
标签: c++ algorithm dictionary caching time-complexity