It seems that the questioner does not know what hash is. It is recommended to lay the foundation of data structure first, and then study the application of redis based on data structure.
Of course, the complexity of hash O(1) refers to the average complexity, and it is also the best case, and the worst case is O(n)
The so-called dictionary is a hash table, and the complexity of addition, deletion and modification of hashmap is linear without too much collision. ~~
The picture below is a schematic diagram of the Hash Table:
Mainly due to optimization
Hash Function
,尽可能的减少冲突。也就是防止不同的key
映射到相同的value
, although it doesn’t matter even if there is a conflict. . .Reference:
http://www.tutorialspoint.com/data_structures_algorithms/hash_data_structure.htm Not sure if you need to circumvent the firewall.
PS: You can read the introduction to algorithms. . .
It seems that the questioner does not know what hash is. It is recommended to lay the foundation of data structure first, and then study the application of redis based on data structure.
Of course, the complexity of hash O(1) refers to the average complexity, and it is also the best case, and the worst case is O(n)
I don’t quite understand. How can the complexity of traversing a linked list be 1?
The so-called dictionary is a hash table, and the complexity of addition, deletion and modification of hashmap is linear without too much collision. ~~