Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the HashMap interview topics?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "what are the HashMap interview topics". In the daily operation, I believe many people have doubts about what HashMap interview topics there are. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what HashMap interview topics are there?" Next, please follow the editor to study!

1. The concept of Hash

The input of any length is mapped to a fixed-length output through the hashing algorithm.

2. Hash conflict

When the set of keywords is very large (when the number of key is large), elements with different key values may be mapped to the same address of the hash table, that is, K1 conflict K2, but f (K1) = f (K2), this phenomenon is called hash conflict. In practice, conflicts are inevitable and can only be reduced by improving the performance of the hash function.

3. What do you think are the points of a good Hash algorithm? (1) the efficiency is high, so that the Hash value can be calculated efficiently in the long text. (2) according to the Hash value, the Hash value cannot be inversely derived from the original text. (3) if there is a slight difference, the Hash value must be different.

(4) distributed as much as possible, because Hash conflicts should be minimized as much as possible when most of the slot is idle in table

4. What is the storage structure of HashMap?

JDK1.8:

(1) Array + linked list + red-black tree. Each data unit is a Node structure. There are key fields, value fields, next fields and hash fields in the Node structure.

(2) the next field is the field needed to connect the Node in the current bucket bit with the conflicting Node to form a linked list when a Hash conflict occurs.

JDK1.7:

Array + linked list

45. If the length of the HashMap hash table is not specified when creating the HashMap, what is the initial length?

In JDK 8, the default capacity is defined as: static final int DEFAULT_INITIAL_CAPACITY = 1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report