13.2 Compare and contrast a hash table and an STL map. What is a hash table implemented? If the number of inputs is small, which data structure options can be used instead of a hash table?
This problem let us compare hash table and STL map data structure, before encountering this problem, I always thought map is C + + hash table, originally is different AH--!!!
A hash table is implemented by a list of linked lists, each of which contains key values, keys, and value value. The data is not stored in order, it is a hash function to calculate the location to be deposited index, the time complexity of finding or inserting data is an order of magnitude O (1), this is a bunker. In the hash table, we want to solve the potential conflict problem, that is, two sets of data to be stored in the same location, we can use the linked list to the same location of the data link up, iron chain serial AH ~
The map is implemented by inserting key value/value pairs in a binary tree based on key value key, eliminating the need to deal with conflicts.
For small input data, we can also use map or two-fork tree to achieve, although the time complexity is O (LGN), but because the input data is small, in fact, there is not much difference.
[Careercup] 13.2 Compare hash table and STL map compare hash table and map