16) Hashing - For this assignment you will declare an array...

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

View Full Document Right Arrow Icon
For this assignment, you will declare an array that can hold up to 10 elements. The elements will be read from a file. Use the modulo-division to come up with a location. If there is a collision, then use double hashing. The formula that you should use for double hashing should be the same as the example provided in the notes. If there is still a collision, then use quadratic probing from the point of the second collision forward three times. If you are still colliding, use linear probing. At the end of each insert, display the number of collisions. Also, allow the user to search for a value by prompting the user. Use the same set of hash functions to look for the item. If the item has not been found, then display not in the list. What is hashing Hashing is a way to have a key|value sequence so that it is easy and fast to find values associated with a key. Or to represent/convert a key to some value Hashing means to chop and mix. A bucket in a hash file is a unit of storage (typically a disk block) that can hold one or more records. The hash function, h, is a function from the set of all search-keys, K, to the set of all bucket addresses, B. Insertion, deletion, and lookup are done in constant time. To insert a record into the structure compute the hash value h(Ki), and place the record in the bucket address returned. For lookup operations, compute the hash value as above and search each record in the bucket for the specific record. To delete simply lookup and remove. Basic Hashing techniques In direct hashing , the key is the address without any algorithmic manipulation Store numbers 0 thru 5 in an array Index 0 1 2 3 4 5 Value 0 1 2 3 4 5 In subtraction hashing the key is transformed to an address by subtracting a fixed number from it.
Image of page 1

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

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