|
|
|
|
|
by light_hue_1
1157 days ago
|
|
I don't think so. You take the first n bytes of your input string. You hash them. You look them up in the dictionary. The lookup is O(1) but hashing your input is O(n). But there's a simple way around this. We have incremental hash functions. When you add a byte to the string and you use an incremental hash, you do a fixed amount of extra work to update the hash. Like that you only need to O(1) extra work to compute the new hash. One trivial incremental hash is to break your input into fixed size chunks, hash each chunk, and xor the chunks together. |
|