To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
Languages
Recent
Show all languages
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Quadratic probing

From Wikipedia, the free encyclopedia

Quadratic probing is an open addressing scheme in computer programming for resolving hash collisions in hash tables. Quadratic probing operates by taking the original hash index and adding successive values of an arbitrary quadratic polynomial until an open slot is found.

An example sequence using quadratic probing is:

Quadratic probing is often recommended as an alternative to linear probing because it incurs less clustering.[1] Quadratic probing exhibits better locality of reference than many other hash table such as chaining; however, for queries, quadratic probing does not have as good locality as linear probing, causing the latter to be faster in some settings.[2]

Quadratic probing was first introduced by Ward Douglas Maurer in 1968.[3]

YouTube Encyclopedic

  • 1/3
    Views:
    87 135
    9 810
    3 416
  • Hashing - Quadratic Probing for Collision Resolution
  • Collision Resolution Technique(2.Quadratic Probing)
  • Quadratic Probing Hash Table Example

Transcription

Quadratic function

Let h(k) be a hash function that maps an element k to an integer in [0, m−1], where m is the size of the table. Let the ith probe position for a value k be given by the function

where c2 ≠ 0 (If c2 = 0, then h(k,i) degrades to a linear probe). For a given hash table, the values of c1 and c2 remain constant.

Examples:

  • If , then the probe sequence will be
  • For m = 2n, a good choice for the constants are c1 = c2 = 1/2, as the values of h(k,i) for i in [0, m−1] are all distinct (in fact, it is a permutation on [0, m−1][4]). This leads to a probe sequence of (the triangular numbers) where the values increase by 1, 2, 3, ...
  • For prime m > 2, most choices of c1 and c2 will make h(k,i) distinct for i in [0, (m−1)/2]. Such choices include c1 = c2 = 1/2, c1 = c2 = 1, and c1 = 0, c2 = 1. However, there are only m/2 distinct probes for a given element, requiring other techniques to guarantee that insertions will succeed when the load factor exceeds 1/2.
  • For , where m, n, and p are integer greater or equal 2 (degrades to linear probe when p = 1), then gives cycle of all distinct probes. It can be computed in loop as: , and
  • For any m, full cycle with quadratic probing can be achieved by rounding up m to closest power of 2, compute probe index: , and skip iteration when . There is maximum skipped iterations, and these iterations do not refer to memory, so it is fast operation on most modern processors. Rounding up m can be computed by:
uint64_t roundUp2(uint64_t v){
	v--;
	v |= v >> 1;
	v |= v >> 2;
	v |= v >> 4;
	v |= v >> 8;
	v |= v >> 16;
	v |= v >> 32;
	v++;
	return v;
}

Limitations

Alternating signs

If the sign of the offset is alternated (e.g. +1, −4, +9, −16, etc.), and if the number of buckets is a prime number congruent to 3 modulo 4 (e.g. 3, 7, 11, 19, 23, 31, etc.), then the first offsets will be unique (modulo ).[further explanation needed] In other words, a permutation of 0 through is obtained, and, consequently, a free bucket will always be found as long as at least one exists.

References

  1. ^ Cormen, Thomas H.; Leiserson, Charles Eric; Rivest, Ronald Linn; Stein, Clifford (2009). Introduction to algorithms (3rd ed.). Cambridge, Massachusetts London, England: MIT Press. ISBN 978-0-262-53305-8.
  2. ^ Richter, Stefan; Alvarez, Victor; Dittrich, Jens (2015). "A seven-dimensional analysis of hashing methods and its implications on query processing". Proceedings of the VLDB Endowment. 9 (3): 96–107. doi:10.14778/2850583.2850585. ISSN 2150-8097.
  3. ^ Maurer, W. D. (1968). "Programming Technique: An improved hash code for scatter storage". Communications of the ACM. 11 (1): 35–38. doi:10.1145/362851.362880. ISSN 0001-0782.
  4. ^ The Art of Computer Science Volume 3 Sorting and Searching, Chapter 6.4, exercise 20, Donald Knuth

External links

This page was last edited on 28 November 2023, at 01:08
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.