Hash Tables

1)What is the expected time to search for an element in a hash table?

2)What is the worst case time for searching a element using hash table.

3)Demonstrate the insertion of the keys 5,28,19,15,20,33,12,17,10 into a hash table with collisions resolved by chaining.Let the table have 9 slots,and let the hash function be h(k)=k mod 9.

4)Suppose we use a hash function to hash m distinct keys into an array T of length m.Assuming simple uniform hashing,what is the expected number of collisions?

5)Suggest how storage for elements can be allocated and deallocated within the hash table itself by linking all unused slots into a free list.Assume that one slot can store a flag and either one element plus a pointer or two pointers.Does the free list need to be doublt linked,or does a singly linked free list suffice?

6)Suppose we wish to search a linked list of length n,where each element contains a key k along with a hash value h(k).Each key is a long character string.How might we take advantage of the hash values when searching the list for an element with a given key?

5 comments:

  1. is the answer for 4th is

    worst case m-1 collisns
    best case 0 collisns

    ??????

    ReplyDelete
  2. 5)Suggest how storage for elements can be allocated and deallocated within the hash table itself by linking all unused slots into a free list.Assume that one slot can store a flag and either one element plus a pointer or two pointers.Does the free list need to be doublt linked,or does a singly linked free list suffice?

    can I get 5th question answer?

    ReplyDelete
  3. http://blog.eitanadler.com/2012_05_01_archive.html

    ReplyDelete