This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: §4 Open Addressing 2. Quadratic Probing f ( i ) = i 2 ; /* a quadratic function */ f ( i ) = i 2 ; /* a quadratic function */ 【 Theorem 【 If quadratic probing is used, and the table size is prime , then a new element can always be inserted if the table is at least half empty . Proof: Just prove that the first TableSize/2 alternative locations are all distinct . That is, for any 0 < i ≠ j ≤ TableSize/2 , we have ( h ( x ) + i 2 ) % TableSize ≠ ( h ( x ) + j 2 ) % TableSize Suppose: h ( x ) + i 2 = h ( x ) + j 2 ( mod TableSize ) then: i 2 = j 2 ( mod TableSize ) ( i + j ) ( i- j ) = 0 ( mod TableSize ) TableSize is prime either ( i + j ) or ( i- j ) is divisible by TableSize Contradiction ! For any x , it has TableSize/2 distinct locations into which it can go. If at most TableSize/2 positions are taken, then an empty spot can always be found. 1/7 §4 Open Addressing Note: If the table size is a prime of the form 4 k + 3, then the quadratic probing f ( i ) = ± i 2 can probe the entire table. Note: If the table size is a prime of the form 4 k + 3, then the quadratic probing f ( i ) = ± i 2 can probe the entire table....
View Full Document
This note was uploaded on 10/20/2011 for the course COMPUTER S 10586 taught by Professor Jilinwang during the Spring '09 term at Zhejiang University.
- Spring '09
- Computer Science