|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
| {{multiple issues|
| | == Elder robust. == |
| {{Original research|article|date=May 2008}}
| |
| {{Howto|date=April 2013}}
| |
| }}
| |
|
| |
|
| '''Quadratic probing''' is an open addressing scheme in [[computer programming]] for resolving collisions in [[hash table]]s—when an incoming data's hash value indicates it should be stored in an already-occupied slot or bucket. Quadratic probing operates by taking the original hash index and adding successive values of an arbitrary [[quadratic polynomial]] until an open slot is found. | | Elder robust,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_62.htm オークリー サングラス レーダー].<br><br>'This is the first Star monster,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_30.htm オークリー サングラス ファストジャケット], was arrested for how long?' Luo Feng low road.<br><br>'two thousand years of it.' Temple Fan Qi elder laments, 'Star behemoth of life is long, I Golden Horn family and human community are the main life Doomsday 1000 era, which is the life of the sky monster Doomsday is tenfold.<br><br>'Why are tied with,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_30.htm オークリー サングラス ファストジャケット]?' Luo Feng low road,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_12.htm スポーツサングラス オークリー].<br><br>Temple Fan Qi Feng Luo elders also found that the tone was not quite right:? 'This is the first Star monster,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_69.htm オークリーサングラス画像], when veteran to be captured, it obstinately refused to surrender to what the status of the veteran community one end of the main peak of the identity of his monster stars basically useless,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_18.htm オークリー サングラス フラックジャケット], just because too rare and why they grabbed. '<br><br>'Yes ah, venerable patriarch of the universe,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_73.htm オークリー サングラス 度付き 価格], of course, do not care a sky monster.' Luo Feng low road.<br>systemic flow<br>'But this is the first Star behemoth is very stubborn, refusing to surrender,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_72.htm ゴルフ用サングラスオークリー], who had worked frantically struggling howling often hear it roar, and struggled when |
| | 相关的主题文章: |
| | <ul> |
| | |
| | <li>[http://home.ejiangtang.com.cn/space.php?uid=278496&do=blog&id=3437482 http://home.ejiangtang.com.cn/space.php?uid=278496&do=blog&id=3437482]</li> |
| | |
| | <li>[http://happy-marron.com/cgi/diary/nicky/nicky.cgi http://happy-marron.com/cgi/diary/nicky/nicky.cgi]</li> |
| | |
| | <li>[http://www.52xiaogan.cn/home.php?mod=space&uid=197566 http://www.52xiaogan.cn/home.php?mod=space&uid=197566]</li> |
| | |
| | </ul> |
|
| |
|
| For a given hash value, the indices generated by [[linear probing]] are as follows:
| | == two years == |
|
| |
|
| <math>H + 1 , H + 2 , H + 3 , H + 4 , ... , H + k</math> | | Large pay, rituximab grinned: 'You are not afraid to stir up trouble, afraid you backwater opportunity to come!!'<br><br>on this,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_70.htm 偏光サングラス オークリー], like investments,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_24.htm ゴルフ オークリー サングラス], spending a principal rituximab had reached 35%,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_37.htm オークリー野球サングラス], such as his large capital investment in the same hit on so much,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_9.htm オークリー 度付きサングラス], be ultra-configured.<br><br>reason for doing so is because Luo Hua Youxin heart,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_43.htm オークリー レディース サングラス]!<br><br>universe from the original 700 billion RMB capital, two years,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_31.htm オークリーのサングラス], rose to 800 billion. Operators earn very little, can Rituximab has not sell, he was waiting for the opportunity!<br><br>'horizontal how long, how high stand there! see who's on the high patience,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_76.htm オークリー サングラス ジャパンフィット], hope this is really the market!' Rituximab is like a head viper, and gazed at the screen, in the universe on the largest investment market , not to mention his two trillion currency universe capital. Is a four-star customer, and even five-star customer.<br><br>had carefully!<br><br>because more is a big investment, it is prone to some financial predators, just maybe,[http://www.alleganycountyfair.org/_vti_cnf/rakuten_oakley_78.htm サングラス オークリー 人気], it |
| | | 相关的主题文章: |
| This method results in [[primary clustering]], and as the cluster grows larger, the search for those items hashing within the cluster becomes less efficient.
| | <ul> |
| | | |
| An example sequence using quadratic probing is:
| | <li>[http://ebookspratiques.com/search.cgi http://ebookspratiques.com/search.cgi]</li> |
| | | |
| <math>H + 1^2 , H + 2^2 , H + 3^2 , H + 4^2 , ... , H + k^2</math>
| | <li>[http://www.ccms.cc/forum.php?mod=viewthread&tid=89308&extra= http://www.ccms.cc/forum.php?mod=viewthread&tid=89308&extra=]</li> |
| | | |
| Quadratic probing can be a more efficient algorithm in a closed hash table, since it better avoids the clustering problem that can occur with linear probing, although it is not immune. It also provides good memory caching because it preserves some [[locality of reference]]; however, linear probing has greater locality and, thus, better cache performance.
| | <li>[http://www.feuerwehr-itzehoe.de/cgi-bin/guestbook/guestbook.cgi http://www.feuerwehr-itzehoe.de/cgi-bin/guestbook/guestbook.cgi]</li> |
| | | |
| Quadratic probing is used in the [[Berkeley Fast File System]] to allocate free blocks. The allocation routine chooses a new cylinder-group when the current is nearly full using quadratic probing, because of the speed it shows in finding unused cylinder-groups.
| | </ul> |
| | |
| ==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 i<sup>th</sup> probe position for a value k be given by the function
| |
| :<math>h(k,i) = ( h(k) + c_1 i + c_2 i^2 ) \pmod{m}</math> | |
| where c<sub>2</sub> ≠ 0. If c<sub>2</sub> = 0, then h(k,i) degrades to a [[linear probing|linear probe]]. For a given [[hash table]], the values of c<sub>1</sub> and c<sub>2</sub> remain constant.
| |
| | |
| '''Examples:'''
| |
| *If <math>h(k,i) = (h(k) + i + i^2) \pmod{m}</math>, then the probe sequence will be <math>h(k), h(k)+2, h(k)+6, ...</math>
| |
| *For m = 2<sup>n</sup>, a good choice for the constants are c<sub>1</sub> = c<sub>2</sub> = 1/2, as the values of h(k,i) for i in [0,m-1] are all distinct. This leads to a probe sequence of <math>h(k), h(k)+1, h(k)+3, h(k)+6, ...</math> where the values increase by 1, 2, 3, ...
| |
| *For prime m > 2, most choices of c<sub>1</sub> and c<sub>2</sub> will make h(k,i) distinct for i in [0, (m-1)/2]. Such choices include c<sub>1</sub> = c<sub>2</sub> = 1/2, c<sub>1</sub> = c<sub>2</sub> = 1, and c<sub>1</sub> = 0, c<sub>2</sub> = 1. Because there are only about m/2 distinct probes for a given element, it is difficult to guarantee that insertions will succeed when the load factor is > 1/2.
| |
| | |
| == Quadratic probing insertion ==
| |
| | |
| The problem, here, is to insert a key at an available key space in a given Hash Table using quadratic probing.<ref>{{cite book|last=Horowitz, Sahni, Anderson-Freed|title=Fundamentals of Data Structures in C|year=2011|publisher=University Press|isbn=978-81-7371-605-8}}</ref>
| |
| | |
| === Algorithm to insert key in hash table ===
| |
| | |
| <code>
| |
| 1. Get the key k
| |
| 2. Set counter j = 0
| |
| 3. Compute hash function h[k] = k % SIZE
| |
| 4. If hashtable[h[k]] is empty
| |
| (4.1) Insert key k at hashtable[h[k]]
| |
| (4.2) Stop
| |
| Else
| |
| (4.3) The key space at hashtable[h[k]] is occupied, so we need to find the next available key space
| |
| (4.4) Increment j
| |
| (4.5) Compute new hash function h[k] = ( k + j * j ) % SIZE
| |
| (4.6) Repeat Step 4 till j is equal to the SIZE of hash table
| |
| 5. The hash table is full
| |
| 6. Stop
| |
| </code>
| |
| | |
| === C function for key insertion ===
| |
| <source lang="c">
| |
| | |
| int quadratic_probing_insert(int *hashtable, int key, int *empty)
| |
| {
| |
| /* hashtable[] is an integer hash table; empty[] is another array which indicates whether the key space is occupied;
| |
| If an empty key space is found, the function returns the index of the bucket where the key is inserted, otherwise it
| |
| returns (-1) if no empty key space is found */
| |
| | |
| int j = 0, hk;
| |
| hk = key % SIZE;
| |
| while(j < SIZE)
| |
| {
| |
| if(empty[hk] == 1)
| |
| {
| |
| hashtable[hk] = key;
| |
| empty[hk] = 0;
| |
| return (hk);
| |
| }
| |
| j++;
| |
| hk = (key + j * j) % SIZE;
| |
| }
| |
| return (-1);
| |
| }
| |
| | |
| </source>
| |
| | |
| == Quadratic probing search ==
| |
| | |
| === Algorithm to search element in hash table ===
| |
| | |
| <code> | |
| 1. Get the key k to be searched
| |
| 2. Set counter j = 0
| |
| 3. Compute hash function h[k] = k % SIZE
| |
| 4. If the key space at hashtable[h[k]] is occupied
| |
| (4.1) Compare the element at hashtable[h[k]] with the key k.
| |
| (4.2) If they are equal
| |
| (4.2.1) The key is found at the bucket h[k]
| |
| (4.2.2) Stop
| |
| Else
| |
| (4.3) The element might be placed at the next location given by the quadratic function
| |
| (4.4) Increment j
| |
| (4.5) Compute new hash function h[k] = ( k + j * j ) % SIZE
| |
| (4.6) Repeat Step 4 till j is greater than SIZE of hash table
| |
| 5. The key was not found in the hash table
| |
| 6. Stop
| |
| </code> | |
| | |
| === C function for key searching ===
| |
| | |
| <source lang="c"> | |
| int quadratic_probing_search(int *hashtable, int key, int *empty)
| |
| {
| |
| /* If the key is found in the hash table, the function returns the index of the hashtable where the key is inserted, otherwise it
| |
| returns (-1) if the key is not found */
| |
| | |
| int j = 0, hk;
| |
| hk = key % SIZE;
| |
| while(j < SIZE)
| |
| {
| |
| if((empty[hk] == 0) && (hashtable[hk] == key))
| |
| return (hk);
| |
| j++;
| |
| hk = (key + j * j) % SIZE;
| |
| }
| |
| return (-1);
| |
| }
| |
| </source>
| |
| | |
| ==Limitations==
| |
| | |
| <ref>{{cite book|first=Mark Allen Weiss|title=Data Structures and Algorithm Analysis in C++|year=2009|publisher=Pearson Education|isbn=978-81-317-1474-4}}</ref> For linear probing it is a bad idea to let the hash table get nearly full, because performance is degraded as the hash table gets filled.
| |
| In the case of quadratic probing, the situation is even more drastic. With the exception of the triangular number case for a power-of-two-sized hash table, there is no guarantee of finding an empty cell once the table gets more than half full, or even before the table gets half full if the table size is not prime. This is because at most half of the table can be used as alternative locations to resolve collisions.
| |
| If the hash table size is b (a prime greater than 3), it can be proven that the first <math> b / 2 </math> alternative locations including the initial location h(k) are all distinct and unique.
| |
| Suppose, we assume two of the alternative locations to be given by <math> h(k) + x^2 \pmod{b} </math> and <math> h(k) + y^2 \pmod{b} </math>, where 0 ≤ x, y ≤ (b / 2).
| |
| If these two locations point to the same key space, but x ≠ y. Then the following would have to be true,
| |
| <math> h(k) + x^2 = h(k) + y^2 \pmod{b} </math>
| |
| <math> x^2 = y^2 \pmod{b} </math>
| |
| <math> x^2 - y^2 = 0 \pmod{b} </math>
| |
| <math> (x - y)(x + y) = 0 \pmod{b} </math>
| |
| As b (table size) is a prime greater than 3, either (x - y) or (x + y) has to be equal to zero.
| |
| Since x and y are unique, (x - y) cannot be zero.
| |
| Also, since 0 ≤ x, y ≤ (b / 2), (x + y) cannot be zero.
| |
| | |
| Thus, by contradiction, it can be said that the first (b / 2) alternative locations after h(k) are unique.
| |
| So an empty key space can always be found as long as at most (b / 2) locations are filled, i.e., the hash table is not more than half full.
| |
| | |
| ==See also==
| |
| * [[Hash tables]]
| |
| * [[Hash collision]]
| |
| * [[Double hashing]]
| |
| * [[Linear probing]]
| |
| * [[Hash function]]
| |
| | |
| ==References==
| |
| {{Reflist}}
| |
| | |
| ==External links==
| |
| *[http://research.cs.vt.edu/AVresearch/hashing/quadratic.php Tutorial/quadratic probing]
| |
| | |
| [[Category:Hashing]]
| |
Elder robust.
Elder robust,オークリー サングラス レーダー.
'This is the first Star monster,オークリー サングラス ファストジャケット, was arrested for how long?' Luo Feng low road.
'two thousand years of it.' Temple Fan Qi elder laments, 'Star behemoth of life is long, I Golden Horn family and human community are the main life Doomsday 1000 era, which is the life of the sky monster Doomsday is tenfold.
'Why are tied with,オークリー サングラス ファストジャケット?' Luo Feng low road,スポーツサングラス オークリー.
Temple Fan Qi Feng Luo elders also found that the tone was not quite right:? 'This is the first Star monster,オークリーサングラス画像, when veteran to be captured, it obstinately refused to surrender to what the status of the veteran community one end of the main peak of the identity of his monster stars basically useless,オークリー サングラス フラックジャケット, just because too rare and why they grabbed. '
'Yes ah, venerable patriarch of the universe,オークリー サングラス 度付き 価格, of course, do not care a sky monster.' Luo Feng low road.
systemic flow
'But this is the first Star behemoth is very stubborn, refusing to surrender,ゴルフ用サングラスオークリー, who had worked frantically struggling howling often hear it roar, and struggled when
相关的主题文章:
two years
Large pay, rituximab grinned: 'You are not afraid to stir up trouble, afraid you backwater opportunity to come!!'
on this,偏光サングラス オークリー, like investments,ゴルフ オークリー サングラス, spending a principal rituximab had reached 35%,オークリー野球サングラス, such as his large capital investment in the same hit on so much,オークリー 度付きサングラス, be ultra-configured.
reason for doing so is because Luo Hua Youxin heart,オークリー レディース サングラス!
universe from the original 700 billion RMB capital, two years,オークリーのサングラス, rose to 800 billion. Operators earn very little, can Rituximab has not sell, he was waiting for the opportunity!
'horizontal how long, how high stand there! see who's on the high patience,オークリー サングラス ジャパンフィット, hope this is really the market!' Rituximab is like a head viper, and gazed at the screen, in the universe on the largest investment market , not to mention his two trillion currency universe capital. Is a four-star customer, and even five-star customer.
had carefully!
because more is a big investment, it is prone to some financial predators, just maybe,サングラス オークリー 人気, it
相关的主题文章: