Homework 4  - Searching

 

1.    Assume the values A through H are stored in a self organizing list initially in ascending order.  For each of the three updates described in class (sort by access frequency, move to front (not swap with front), swap with previous), show the resulting list, and number of comparisons resulting from the following series of accesses

D H H G H E G H G H E C E H G

2.    Using closed hashing, with double hashing to resolve collisions, insert the following keys into a hash table of 13 slots.  The hash functions to be used are H1(k)=k mod 13 and H2(k)=Rev(k+1) mod 11.  Where Rev(k) is k with the digits reversed.  For example, Rev(48)=84.  Show the hash table and give the total number of collisions after inserting the following values:

2 8 31 20 19 18 53 27