F1 score: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Monkbot
reason -> reasons
Line 1: Line 1:
[[Image:cuckoo.svg|thumb|Cuckoo hashing example. The arrows show the alternative location of each key. A new item would be inserted in the location of A by moving A to its alternative location, currently occupied by B, and moving B to its alternative location which is currently vacant. Insertion of a new item in the location of H would not succeed: Since H is part of a cycle (together with W), the new item would get kicked out again.]]
The author's title is Christy Brookins. Credit authorising is how she makes a residing. The preferred hobby for him and his kids is fashion and he'll be starting something else alongside with it. North Carolina is the location he loves most but now he is contemplating other choices.<br><br>My page - best psychics; [http://www.article-galaxy.com/profile.php?a=143251 article-galaxy.com],
 
'''Cuckoo hashing''' is a scheme in [[computer programming]] for resolving [[hash collision]]s of values of [[hash function]]s in a [[hash table|table]], with [[worst case analysis|worst-case]] [[constant time|constant]] lookup time. The name derives from the behavior of some species of [[cuckoo]], where the cuckoo chick pushes the other eggs or young out of the nest when it hatches; analogously, inserting a new key into a cuckoo hashing table may push an older key to a different location in the table.
 
==History==
Cuckoo hashing was first described by [[Rasmus Pagh]] and [[Flemming Friche Rodler]] in 2001.<ref name="Cuckoo">{{cite doi|10.1007/3-540-44676-1_10}}</ref>
 
==Theory==
The basic idea is to use two hash functions instead of only one. This provides two possible locations in the hash table for each [[unique key|key]]. In one of the commonly used variants of the algorithm, the hash table is split into two smaller tables of equal size, and each hash function provides an index into one of these two tables.
 
When a new key is inserted, a [[greedy algorithm]] is used: The new key is inserted in one of its two possible locations, "kicking out", that is, displacing, any key that might already reside in this location. This displaced key is then inserted in its alternative location, again kicking out any key that might reside there, until a vacant position is found, or the procedure would enter an [[infinite loop]]. In the latter case, the [[hash table]] is rebuilt [[in-place algorithm|in-place]] using new [[hash function]]s:{{quote | text = There is no need to allocate new tables for the rehashing: We may simply run through the tables to delete and perform the usual insertion procedure on all keys found not to be at their intended position in the table. | sign = Pagh & Rodler | source = "Cuckoo Hashing"<ref name=Cuckoo/> }}
 
Lookup requires inspection of just two locations in the hash table, which takes constant time in the worst case (''see'' [[Big O notation]]). This is in contrast to many other hash table algorithms, which may not have a constant worst-case bound on the time to do a lookup.
 
It can also be shown that insertions succeed in expected constant time,<ref name="Cuckoo" /> even considering the possibility of having to rebuild the table, as long as the number of keys is kept below half of the capacity of the hash table, i.e., the load factor is below 50%. One method of proving this uses the theory of [[random graph]]s: one may form an [[undirected graph]] called the "Cuckoo Graph" that has a vertex for each hash table location, and an edge for each hashed value, with the endpoints of the edge being the two possible locations of the value. Then, the greedy insertion algorithm for adding a set of values to a cuckoo hash table succeeds if and only if the Cuckoo Graph for this set of values is a [[pseudoforest]], a graph with at most one cycle in each of its [[connected component (graph theory)|connected component]]s, as any vertex-induced subgraph with more edges than vertices corresponds to a set of keys for which there are an insufficient number of slots in the hash table. This property is true with high probability for a random graph in which the number of edges is less than half the number of vertices.<ref>{{Cite web|first=Reinhard|last=Kutzelnigg|url=http://www.dmtcs.org/dmtcs-ojs/index.php/proceedings/article/viewFile/590/1710|contribution=Bipartite random graphs and cuckoo hashing|title=Fourth Colloquium on Mathematics and Computer Science|series=Discrete Mathematics and Theoretical Computer Science|year=2006|volume=AG|pages=403–406|postscript=<!-- Bot inserted parameter. Either remove it; or change its value to "." for the cite to end in a ".", as necessary. -->{{inconsistent citations}}}}</ref>
 
== Example ==
The following hashfunctions are given:
 
<math>h\left(k\right)=k\mod 11</math><br/>
<math>h'\left(k\right)=\left\lfloor\frac{k}{11}\right\rfloor\mod 11</math>
 
<div style="float:left; margin-right:1em">
{| class="wikitable"
|-
! k !! h(k) !! h'(k)
|-
| 20 || 9 || 1
|-
| 50 || 6 || 4
|-
| 53 || 9 || 4
|-
| 75 || 9 || 6
|-
| 100 || 1 || 9
|-
| 67 || 1 || 6
|-
| 105 || 6 || 9
|-
| 3 || 3 || 0
|-
| 36 || 3 || 3
|-
| 39 || 6 || 3
|}
</div>
 
Columns in the following two tables show the state of the hash tables over time as the elements are inserted.
 
<div style="float:left; margin-right:1em">
{| class="wikitable"
|-
! colspan="11" | 1. table for h(k)
|-
| || 20 || 50 || 53 || 75 || 100 || 67 || 105 || 3 || 36 || 39
|-
| 0 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 1 ||  ||  ||  ||  || 100 || 67 || 67 || 67 || 67 || 100
|-
| 2 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 3 ||  ||  ||  ||  ||  ||  ||  || 3 || 3 || 36
|-
| 4 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 5 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 6 ||  || 50 || 50 || 50 || 50 || 50 || 105 || 105 || 105 || 50
|-
| 7 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 8 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 9 || 20 || 20 || 20 || 20 || 20 || 20 || 53 || 53 || 53 || 75
|-
| 10 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|}
</div>
 
<div style="float:left">
{| class="wikitable"
|-
! colspan="11" | 2. table for h'(k)
|-
| || 20 || 50 || 53 || 75 || 100 || 67 || 105 || 3 || 36 || 39
|-
| 0 ||  ||  ||  ||  ||  ||  ||  ||  ||  || 3
|-
| 1 ||  ||  ||  ||  ||  ||  || 20 || 20 || 20 || 20
|-
| 2 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 3 ||  ||  ||  ||  ||  ||  ||  ||  || 36 || 39
|-
| 4 ||  ||  || 53 || 53 || 53 || 53 || 50 || 50 || 50 || 53
|-
| 5 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 6 ||  ||  ||  || 75 || 75 || 75 || 75 || 75 || 75 || 67
|-
| 7 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 8 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
| 9 ||  ||  ||  ||  ||  || 100 || 100 || 100 || 100 || 105
|-
| 10 ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|}
</div>
<div style="clear:both;" />
 
=== Cycle ===
If you now wish to insert the element 6, then you get into a cycle. In the last row of the table we find the same initial situation as at the beginning again.
 
<math>h\left(6\right)=6\mod 11=6</math><br/>
<math>h'\left(6\right)=\left\lfloor\frac{6}{11}\right\rfloor\mod 11=0</math><br/>
{| class="wikitable"
|-
| considered key || ! colspan="2" | table 1 || ! colspan="2" | table 2
|-
| || old value || new value || old value || new value
|-
| 6 || 50 || 6 || 53 || 50
|-
| 53 || 75 || 53 || 67 || 75
|-
| 67 || 100 || 67 || 105 || 100
|-
| 105 || 6 || 105 || 3 || 6
|-
| 3 || 36 || 3 || 39 || 36
|-
| 39 || 105 || 39 || 100 || 105
|-
| 100 || 67 || 100 || 75 || 67
|-
| 75 || 53 || 75 || 50 || 53
|-
| 50 || 39 || 50 || 36 || 39
|-
| 36 || 3 || 36 || 6 || 3
|-
| 6 || 50 || 6 || 53 || 50
|}
 
==Generalizations and applications==
Generalizations of cuckoo hashing that use more than 2 alternative hash functions can be expected to utilize a larger part of the capacity of the hash table efficiently while sacrificing some lookup and insertion speed. Using just three hash functions increases the load to 91%.<ref name="mitzenmacher2009survey">{{cite journal | last=Mitzenmacher | first=Michael | authorlink=Michael Mitzenmacher|title=Some Open Questions Related to Cuckoo Hashing &#124; Proceedings of ESA 2009 | date=2009-09-09|url=http://www.eecs.harvard.edu/~michaelm/postscripts/esa2009.pdf | format=PDF | accessdate=2010-11-10 }}</ref> Another generalization of cuckoo hashing consists in using more than one key per bucket. Using just 2 keys per bucket permits a load factor above 80%.
 
Other algorithms that use multiple hash functions include the [[Bloom filter]]. Cuckoo hashing can be used to implement a data structure equivalent to a Bloom filter.{{Citation needed|date=February 2011}} A simplified generalization of cuckoo hashing called [[Associative cache|skewed-associative cache]] is used in some CPU caches.{{Citation needed|date=February 2011}}
 
A study by Zukowski et al.<ref>{{cite journal | last=Zukowski | first=Marcin | coauthors=Heman, Sandor; Boncz, Peter | title=Architecture-Conscious Hashing | publisher=Proceedings of the International Workshop on Data Management on New Hardware (DaMoN) | date=June 2006 | doi= | url=http://www.cs.cmu.edu/~damon2006/pdf/zukowski06archconscioushashing.pdf | format=PDF  | accessdate=2008-10-16}}</ref> has shown that cuckoo hashing is much faster than [[Separate chaining|chained hashing]] for small, [[CPU cache|cache]]-resident hash tables on modern processors. Kenneth Ross<ref>{{cite journal | last=Ross | first=Kenneth | title=Efficient Hash Probes on Modern Processors | publisher=IBM Research Report RC24100 | date=2006-11-08 |url=http://domino.research.ibm.com/library/cyberdig.nsf/papers/DF54E3545C82E8A585257222006FD9A2/$File/rc24100.pdf | format=PDF | id=RC24100 | accessdate=2008-10-16 }}</ref> has shown bucketized versions of cuckoo hashing (variants that use buckets that contain more than one key) to be faster than conventional methods also for large hash tables, when space utilization is high. The performance of the bucketized cuckoo hash table was investigated further by Askitis,<ref>{{Cite book | title=Fast and Compact Hash Tables for Integer Keys | first1=Nikolas | last1=Askitis | year=2009 | isbn=978-1-920682-72-9 | url=http://crpit.com/confpapers/CRPITV91Askitis.pdf | pages=113–122 | journal=Proceedings of the 32nd Australasian Computer Science Conference (ACSC 2009) | volume=91}}</ref>
with its performance compared against alternative hashing schemes.
 
A survey by [[Michael Mitzenmacher|Mitzenmacher]]<ref name="mitzenmacher2009survey" /> presents open problems related to cuckoo hashing as of 2009.
 
== See also ==
 
* [[Perfect hashing]]
* [[Linear probing]]
* [[Double hashing]]
* [[Hash collision]]
* [[Hash function]]
* [[Quadratic probing]]
* [[Hopscotch hashing]]
 
== References ==
{{Reflist}}
 
==External links==
* [http://www.ru.is/faculty/ulfar/CuckooHash.pdf A cool and practical alternative to traditional hash tables], U. Erlingsson, M. Manasse, F. Mcsherry, 2006.
* [http://www.it-c.dk/people/pagh/papers/cuckoo-undergrad.pdf Cuckoo Hashing for Undergraduates, 2006], R. Pagh, 2006.
* [http://mybiasedcoin.blogspot.com/2007/06/cuckoo-hashing-theory-and-practice-part.html Cuckoo Hashing, Theory and Practice] (Part 1, [http://mybiasedcoin.blogspot.com/2007/06/cuckoo-hashing-theory-and-practice-part_15.html Part 2] and [http://mybiasedcoin.blogspot.com/2007/06/cuckoo-hashing-theory-and-practice-part_19.html Part 3]), Michael Mitzenmacher, 2007.
* {{cite conference | last = Naor | first = Moni | coauthors = Segev, Gil; Wieder, Udi | author2-link = http://www.wisdom.weizmann.ac.il/~gils/ | title = History-Independent Cuckoo Hashing | booktitle = International Colloquium on Automata, Languages and Programming (ICALP) | place = Reykjavik, Iceland | year = 2008 | url = http://www.wisdom.weizmann.ac.il/~naor/PAPERS/cuckoo_hi_abs.html | accessdate = 2008-07-21 }}
 
===Examples===
*[http://github.com/efficient/libcuckoo Concurrent high-performance Cuckoo hashtable written in C++]
* [http://sourceforge.net/projects/cuckoo-cpp/ Cuckoo hash map written in C++]
* [http://www.theiling.de/projects/lookuptable.html Static cuckoo hashtable generator for C/C++]
* [http://lmonson.com/blog/?p=100 Cuckoo hashtable written in Java]
* [http://github.com/joacima/Cuckoo-hash-map/blob/master/CuckooHashMap.java Generic Cuckoo hashmap in Java]
* [http://hackage.haskell.org/packages/archive/hashtables/latest/doc/html/Data-HashTable-ST-Cuckoo.html Cuckoo hash table written in Haskell]
 
[[Category:Search algorithms]]
[[Category:Hashing]]
 
[[pl:Tablica mieszająca#Haszowanie kuku.C5.82cze]]

Revision as of 14:56, 28 February 2014

The author's title is Christy Brookins. Credit authorising is how she makes a residing. The preferred hobby for him and his kids is fashion and he'll be starting something else alongside with it. North Carolina is the location he loves most but now he is contemplating other choices.

My page - best psychics; article-galaxy.com,