Ahash tableorhash mapis adata
structurethat uses ahash functionto map identifying values, known askeys(e.g.,
a person's name), to their associatedvalues(e.g., their telephone number). A
hash table implements anassociative array. The hash function is used to transform the key into
the index (thehash) of anarrayelement (theslotorbucket) where the
corresponding value is to be sought.
The implementation of this calculation is thehash
function,f:
index = f(key, arrayLength)
The hash function calculates anindexwithin the array from the datakey.arrayLengthis
the size of the array.
A basic requirement is that the function should provide auniform
distributionof hash values.
Load factor
The performance of most collision resolution methods does not depend directly on the numbernof stored entries, but depends strongly on the table'sload factor, the ration/sbetweennand
the sizesof its array of buckets.
Separate chaining
In the strategy known asseparate chaining,direct
chaining, or simplychaining, each slot of the bucket array is a pointer to alinked listthat
contains the key-value pairs that hashed to the same location. Lookup requires scanning the list for an entry with the given key. Insertion requires adding a new entry record to either end of the list belonging to the hashed slot. Deletion requires searching
the list and removing the element.
Dynamic resizing
To keep the load factor under a certain limit,
e.g. under 3/4, many table implementations expand the table when items are inserted.
Resizing is accompanied by a full or incremental tablerehashwhereby existing items are mapped to new bucket locations.
To limit the proportion of memory wasted due to empty buckets, some implementations also shrink the size of the table—followed by a rehash—when items are deleted. From the point ofspace-time
tradeoffs, this operation is similar to the deallocation in dynamic arrays.
Resizing by copying all entries
A common approach is to automatically trigger a complete resizing when the load factor exceeds some thresholdrmax. Then a new larger table isallocated,
all the entries of the old table are removed and inserted into this new table, and the old table is returned to the free storage pool. Symmetrically, when the load factor falls below a second thresholdrmin, all
entries are moved to a new smaller table.
http://blog.csdn.net/eaglex/article/details/6305997
http://www.360doc.com/content/11/0817/11/18042_141124440.shtml
分享到:
相关推荐
哈希表 用于哈希表等的 C 宏
(1) 建立一个哈希表,哈希函数为除留余数法,处理冲突的方法为线性探测再散列或二次探测再散列。 (2) 往哈希表中依次存入插入多个单词。 (3) 显示哈希表的存储情况。 (4) 计算哈希表的平均查找长度。 (5) ...
这个小程序实现了哈希表的主要内容。有哈希函数、冲突避免,实现了插入和查找。主要是作为一个教学的例子存在。 本程序用Visual Studio 2005实现。
【问题描述】 利用哈希表进行存储。...哈希表(Hash table)是一种基于哈希函数(Hash function)实现的数据结构,用于实现关联数组或者映射等抽象数据类型。哈希表将元素的键(key)通过哈希函数转换为哈希值
1. 基础知识 3 2. 环的原子管理算法 4 3. 路由算法 10 4. 组通信算法 15 5. 副本管理算法 17 6. 分布式哈希表的应用 21 1. 基
哈希表(Hash Table)是一种高效的数据结构
自己整理的数据结构哈希表详解,参考其他博客、算法导论。包括哈希表构造方法、解决冲突的方法、包含牛客上的练习题。
根据算法导论上的HashTable, C语言实现
hash_map基于hash table(哈希表)。 哈希表最大的优点,就是把数据的存储和查找消耗的时间大大降低,几乎可以看成是常数时间;而代价仅仅是消耗比较多的内存。然而在当前可利用内存越来越多的情况下,用空间换时间...
哈希表
哈希表,数据结构,完整代码,值得学习。C++语言
分布式哈希表技术(Distributed Hash Table)简称DHT,类似Tracker的根据种子特征码返回种子信息的网络.是一种分布式存储方法。
上海交通大学计算机系数据结构作业,以哈希表为基础,输入单词进行映射。
一个简单的hash table实现类,实现了插入删除查询操作
hash命令负责显示与清除命令运行时系统优先查询的哈希表(hash table)。 当执行hash命令不指定参数或标志时,hash命令向标准输出报告路径名列表的内容。此报告含有先前hash命令调用找到的当前shell环境中命令的路径...
本文主要是讲”哈希表的存储效率一般不超过50%”的原因。 Hash Table 常用于频繁进行 key/value 模式的查找中。(查找模式,如匹配查找) 哈希表最大的优点在于查找速度快,但存储时可能发生collision(冲突)。 哈希表...
JS版的哈希表,仿C#版,但有些功能更好用
哈希映射 hash map hash_map基于hash table(哈希表)。哈希表最大的优点,就是把数据的存储和查找消耗的时间大大降低,几乎可以看成是常数时间;而代价仅仅是消耗比较多的内存。然而在当前可利用内存越来越多的情况...