Dictionary is an abstract data type used to store data items that can be indexed by key. Basic operations include insertion, search, and deletion. It is a relatively broad concept and does not specify specific implementation, such as what data structure is used to store data items at the underlying layer. Therefore, as long as each data item stored is a pair (Key, value) and can be indexed to this item with key, such a data type can be called dictionary.
 
 
 
 
 
Both direct-address tables and hash tables are specific implementation methods of dictionary. Direct-address tables is actually a normal array. The K entry of the array is only used to store data items whose key value is K. Obviously, to apply such a data structure, you must reserve an array for each possible key value. Therefore, it is only applicable when the key value set is small. Although direct-address tables seems to be a waste of memory, it also has its advantages: the time complexity of insert, search, and delete operations is O (1 ).
 
 
 
 
 
Hash Tables is an effective implementation of dictionary. It solves the problem that direct-address tables is not applicable when the key-value set is large. Assume that the u table shows a set of all possible key values. k indicates the set of key values to be stored. When | u | is much larger than | K |, hash tables only allocates data table items proportional to | K | size, and then maps K to each table item through the hash function. Hash Tables maps key values with a large value range to a small set, which greatly saves storage space, but also introduces collision, that is, when several key values are mapped to the same table item. Due to the complexity of collision processing, the time complexity of operations such as search and deletion is often no longer O (1), or even O (n) in the worst case) (N = | K | ). However, in practice, by selecting an appropriate hash function, the time complexity of the above operations can often be controlled close to O (1 ).