Question
Hash Table vs STL Map: Compare and contrast a hash table and an STL map. How is a hash table implemented? If the number of inputs is small, which data structure options can be used instead of a hash table?
解答
如果使用HashTable,那么我们对元素操作(插入,删除,更改)的时间复杂度为O(1)。
如果使用Map,我们单词操作的时间复杂度是O(logN)。
总结:按自己不同的需要决定在这二者中选择哪一个。