algorithm-base/animation-simulation/数据结构和算法/Hash表的那些事.md

368 lines
25 KiB
Java
Raw Normal View History

2021-03-20 08:57:12 +00:00
> **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
>
>
>
> <u>[****](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
2021-03-20 07:58:25 +00:00
#
********广
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/脑图.1pk584kfatxc.png)
> 穿
![image-20201117132633797](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201117132633797.5dlsgarvplc0.png)
使
###
-------访**hasing******
1************
2)****访
**f**使
** = f ()**
**** **()**
**** **f** ,使 **key** **f(key)**
![image-20201117145348616](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201117145348616.7l7om0vd7ww0.png)
**f** ------**()**
**f(k4) = f(k3)** ******k3** **k4** **f** ****
1************
2********使?
3********
###
####
0-9 **f(key) = key**;
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/直接定址法.b74l6bhzm0w.png)
访
50+ f(key) = key + 50线
**f(key) = a * key + b** **a,b**
####
6 3 3
![image-20201117161754010](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201117161754010.7k9ilkvmcfk0.png)
####
123456789 123 456 789 1368 368
####
key p p m
**f(k) = k mod p (p <= m)**
12 m = 12 p 12** k = 100 f(k) = 100 % 12 = 4**
p p 66p0![image-20201117191635083](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201117191635083.4z4tf8bvv2g0.png)
p
- m 2 m = 2^p f(k) k p 12 % 8 = 4 121100100
- m , p m 20
> ****110
>
> ****
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/质因子.75q2ya0sdts0.png)
235
5 p 6 36
![image-20201117192738889](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201117192738889.4zt1f4q8isc0.png)
####
- k A(0 < A < 1) k A
- m
**f (k) = m(kA mod 1) **
**kA mod 1** keyA **kA - kA**
m 2 m = 2 ^ p ,p
####
321 103041 3 030 304 1234 1522756 3 227 .
广
####
**f(key) = random(key)**random
ASCII
###
使 hash key1 key2 f(key1) = f(key2)
####
>
>
>
>
>
>
> ****
>
>
穿穿
-----
****使******线**
##### 线
线
> **f,(key) = ( f(key) + di ) MOD mdi = 1,2,3,4,5,6....m-1**
{126756162537222915474821}12 **f(key) = key mod 12**
key f(key)
![image-20201118121740324](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118121740324.26hu17vbf5fk.png)
**f(key)** **f(37) = f(25) = 1**, **f(37) = f (f(37) + 1 ) mod 12 = 2**
![image-20201118121801671](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118121801671.6g0iqe60o9c0.png)
**线**线
![线](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/线性探测法.36c7dqr0r120.gif)
48 37 ****使
线21 34
![image-20201118133459372](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118133459372.2vdk7gxr7hg0.png)
10 使线
#####
di
> **线 f,(key) = ( f(key) + di ) MOD mdi = 1,2,3,4,5,6....m-1**
>
> **** **f,(key) = ( f(key) + di ) MOD mdi =1^2 , -1^2 , 2^2 , -2^2 .... q^2, -q^2, q<=m/2**
** -1^2 -1)^2**
34di = -1
![image-20201118142851095](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118142851095.5hdys12bsgg0.png)
.
#####
> 1************
****使 di **************** di ****
> Random Seed
![image-20201118154853554](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118154853554.36a1ec591620.png)
![image-20201118205305792](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118205305792.3czdgupb1540.png)
使
####
> **f,(key) = RH,( key ) (i = 1,2,3,4.....k)**
RH,使
####
>
>
>
>
>
>
> 西
key f(key) {126756162537222915474821}12 **f(key) = key mod 12**
![image-20201118161354566](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/image-20201118161354566.139yir8z205s.png)
####
> .....
>
>
>
> 饿
>
>
>
>
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/溢出区法.6oq4m66ei000.png)
### (线)
elemcountsizeNULLKEY
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/第一行.70gxkpul4fc0.png)
1 key
2线
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/第二行.cph9jb8m24o.png)
1 key
2 key key 线
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/第三张.4iqbtyns3li0.png)
![](https://cdn.jsdelivr.net/gh/tan45du/tan45du.github.io.photo@master/photo/第四张.2uwq29s75o80.png)
###
O(1),
**1.**
**2.**
使线
**3.**
使
> α = /
α 126 α = 6 / 12 = 0.5 α 便