title: polynomial hash function java?
body: <p>whenever i try to generate an index value , i get many collisions at one index . Highest collisions at one index 300 and second highest is like 10. The problem i think is that if words are of length 1, 2, 3 . They usually result in the smaller powers and hence produce a smaller number. Resulting in it getting added to buckets where the number is small. Is there a poly function where this does not happen ? or could you help me fix this problem ?  </p>
  
  <pre><code>public int GetHashCompress(String str ){
      int ply=0;
      double mathIt=0;
      int size = str.length();
      for(int j = 0 ; j&lt; size ; j++){
          double x0 =  (double) str.charAt(j); 
          double firstStep = (int) Math.pow(31, (size-j))*x0;
          mathIt = mathIt + firstStep  ;      // hash function +1 to increance  the range to keep 33 to the power &gt;1 
  
          }
      //arrayOfRawHash.add(mathIt); // this is for testing it later
      ply =(int) mathIt %numBucket;// this is where it is compressed 
      return ply; 
  
  }
  </code></pre>