DS08_Ch07b - 4 Open Addressing 2 Quadratic Probing ff ii)=...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
§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
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
§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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern