当前位置:网站首页>What is hash conflict? How to resolve hash conflicts?
What is hash conflict? How to resolve hash conflicts?
2022-07-22 00:15:00 【Xun Feng】
One 、 Hashtable
Hash table is a kind of key corresponding value (key-indexed) Structure to store data , Just enter the key you want to find key, You can find the corresponding value .
Key as index , In this way, you can quickly access the value of any key .
1.1 hash function
Hash function is a function that maps the key value of an element in a hash table to its storage location .
The elements in the hash table are determined by the hash function . The key word of the data element K As an independent variable , Through certain functional relations ( It's called a hash function ), The calculated value , That is, the storage address of the element .
A suitable hash function , You need to have the following two points
- Homogeneity k The values of are evenly distributed in the hash table ;
- Simple To improve the speed of address calculation ;
1.2 Hash Collisions
Different values , The hash value calculated by the hash function may be the same
Suppose we will need to save the number n, Stored index value = n % 10
Now we need to 20 Save in this form , The calculated key value is 0, But the location already has data , That is, there is a hash conflict .
1.3 Resolve hash conflict
1.3.1 Open address method
Open addressing is when there is a conflict , Just look for the next empty hash address , As long as the hash table is large enough , Empty hash addresses can always be found , Then store the data in this location .
1.3.2 Chain address ( a key )
Treat the nodes of each hash table as the head of a linked list, the root node of a tree, or other data structures .
for example , Treat the node of the hash table as the head of a linked list . take 20 The hash table stored between .
边栏推荐
- FigDraw 16. Dendrogram of SCI article drawing
- Lamp架构——mysql集群及组复制(3)
- Deploy tidb in multiple data centers in the same city
- Intranet detection 1- working group information collection & intra domain information collection
- TZC 1283: simple sort merge sort
- The danger of testing SQL | don't take it lightly
- Peoplecode variable
- Shell scripts download data by date range and interval
- Software test interview questions and answers [1]
- 正则表达式
猜你喜欢
Implementation of static address book
Use Mysql to query logs slowly
Part 03: SQL syntax tree parsing
Zabbix+分布式數據庫TiDB實現分布式數據庫監控
"Polite interaction, thank you for your participation" and you will have the opportunity to receive Navicat premium 16
Synchronization and mutual exclusion of processes
Example of Cisco configuring VLAN
What happens when you have threads
What information does the process control block (PCB) contain
Deploy tidb in multiple data centers in the same city
随机推荐
The actual case of Cisco configuring single arm routing is very simple
Architecture lamp - routeur MySQL (séparateur lecture - écriture)
Zabbix+ distributed database tidb realizes distributed database monitoring
Lamp Architecture - MySQL high availability switching (MHA high availability)
虛擬機的封裝
ensp配置DHCP
Connections and differences between three-level dispatching
JMeter saves test process data in page form
高可用集群Keepalived
什么是哈希冲突?哈希冲突怎么解决?
JDBC connection / operation database of JMeter
Part 06: pooling Technology
2.Ansible中常用模块
Video 36 Chapter 13
Peoplecode objects and classes
3. Use playbook in ansible
Assembly realizes circular judgment on whether it is a square number by means of conditional transfer
Detailed explanation of NiO's three cores
Parsing the sliding window of TCP
[infrastructure] [flink] Flink / Flink CDC code to achieve business access