PS3 - program work correctly for both insertions and searches and if so is it a good hash function Function random(n returns a random integer

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Department of Electrical and Computer Engineering McGill University ECSE-322 Computer Engineering Fall 2010 Problem Set 3 1. Explain the following terms in your own words: Hash function Collision Bucket Hashing Probe 2. Use the has function K(key)= key mod 11 to store the sequence of integers 82, 31, 28, 4, 45, 27, 59, 79, 35 In an array of 11 integers. If a collision occurs, create a re-hashing function. Explain why you have chosen the particular re-hashing functions. 3. Assume that you are hashing key K to a hash table of n slots (indexed from 0 to n-1). For each of the following functions h(K), is the function acceptable as a hash function (i.e., would they hash
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: program work correctly for both insertions and searches), and, if so, is it a good hash function? Function random(n) returns a random integer between 0 and n-1 inclusive. (a) h(k) = k/n where k and n are integers (b) h(k) = 1. (c) h(k) = (k + random(n)) mod n (d) h(k) = k mod n where n is a prime number Examples taken from “Data Structures”by Stubbs and Webre, 2 nd Edition, Brookes-Cole, 1989 and “A Practical Introduction to Data Structures and Algorithm Analysis:, C.A.Shaffer, Prentice-Hall, 1997 ....
View Full Document

This note was uploaded on 11/22/2010 for the course ECSE ECSE 322 taught by Professor Lowther during the Winter '04 term at McGill.

Ask a homework question - tutors are online