item remainder mid-square table comparisons of remainder and mid-square methods figure hashing string using ordinal values we can then take these three ordinal valuesadd them upand use the remainder method to get hash value (see figure the code below shows function called hash that takes string and table size and returns the hash value in the range from to table_size- def hash(a_stringtable_size)sum for pos in range(len(a_string))sum sum ord(a_string[pos]return sum table_size it is interesting to note that when using this hash functionanagrams will always be given the same hash value to remedy thiswe could use the position of the character as weight figure shows one possible way to use the positional value as weighting factor the modification to the hash function is left as an exercise you may be able to think of number of additional ways to compute hash values for items in collection the important thing to remember is that the hash function has to be efficient so that it does not become the dominant part of the storage and search process if the hash function is too complexthen it becomes more work to compute the slot name than it would be to simply do basic sequential or binary search as described earlier this would quickly defeat the purpose of hashing collision resolution we now return to the problem of collisions when two items hash to the same slotwe must have systematic method for placing the second item in the hash table this process is called collision resolution as we stated earlierif the hash function is perfectcollisions will never sorting and searching