[Careercup] 13.2 Compare hash table and STL map compare hash table and map

Source: Internet
Author: User
Tags map data structure

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.