updat format
This commit is contained in:
+7
-7
@@ -36,16 +36,16 @@ for (int i=0;i<s.length();i++){
|
||||
将大小为M的数组中的每个元素指向一条链表,链表中的每个节点都存储了散列值为该元素索引的键值对。每条链表的平均长度是N/M,N是键值对的总个数。
|
||||
|
||||
添加操作:
|
||||
1. 通过hash函数得到hashCode
|
||||
2. 通过hashcode得到index
|
||||
3. 如果index处没有链表,建立好新结点,作为新链表的首结点
|
||||
4. 如果index处已经有链表,先要遍历看key是否已经存在,如果存在直接返回,如果不存在,加入链表头部
|
||||
1. 通过hash函数得到hashCode
|
||||
2. 通过hashcode得到index
|
||||
3. 如果index处没有链表,建立好新结点,作为新链表的首结点
|
||||
4. 如果index处已经有链表,先要遍历看key是否已经存在,如果存在直接返回,如果不存在,加入链表头部
|
||||
|
||||
|
||||
删除操作:
|
||||
1. 通过hash函数得到hashCode
|
||||
2. 通过hashcode得到index
|
||||
3. 遍历链表,删除结点
|
||||
1. 通过hash函数得到hashCode
|
||||
2. 通过hashcode得到index
|
||||
3. 遍历链表,删除结点
|
||||
|
||||
|
||||
#### 线性探测法
|
||||
|
||||
Reference in New Issue
Block a user