data structures using step multiply the key by step extract the fractional part of ka step multiply the result of step by the size of hash table (mhencethe hash function can be given ash(ki (ka mod where (ka mod gives the fractional part of ka and is the total number of indices in the hash table the greatest advantage of this method is that it works practically with any value of although the algorithm works better with some valuesthe optimal choice depends on the characteristics of the data being hashed knuth has suggested that the best choice of is (sqrt / example given hash table of size map the key to an appropriate location in the hash table solution we will use and ( ( mod ( ( mod ( ( ( ( mid-square method the mid-square method is good hash function which works in two stepsstep square the value of the key that isfind step extract the middle digits of the result obtained in step the algorithm works well because most or all digits of the key value contribute to the result this is because all the digits in the original key value contribute to produce the middle digits of the squared value thereforethe result is not dominated by the distribution of the bottom digit or the top digit of the original key value in the mid-square methodthe same digits must be chosen from all the keys thereforethe hash function can be given ash(ks where is obtained by selecting digits from example calculate the hash value for keys and using the mid-square method the hash table has memory locations solution note that the hash table has memory locations whose indices vary from to this means that only two digits are needed to map the key to location in the hash tableso when ( when ( observe that the rd and th digits starting from the right are chosen folding method the folding method works in the following two stepsstep divide the key value into number of parts that isdivide into parts knwhere each part has the same number of digits except the last part which may have lesser digits than the other parts