j********6 发帖数: 135 | 1 Design an algorithm for the following problem and provide an analysis of the
algorithm:
Suppose you are given n+k words of memory to use and a sequence of n INSERT,
DELETE, and MEMBER operations to process. The integers 1 through k are the
values of the operations (e.g., INSERT 1, MEMBER k,...).
Explain how to do each of the three operations in constant time, using at
most a constant amount of additional storage space beyond the alloted n+k
words.
Note: You cannot use preprocessing to initialize memory.
先谢过了!是不是要找一种特殊的数据结构? | w********m 发帖数: 1137 | 2 嵌套的hash?
network = {1: {2, 3, 9}} | j********6 发帖数: 135 | 3 谢谢!我也考虑hash table呢. 还没有什么进展
【在 w********m 的大作中提到】 : 嵌套的hash? : network = {1: {2, 3, 9}}
|
|