public RabinKarp(String pat){
  this.pat=pat;
  R=256;
  m=pat.length();
  q=longRandomPrime();
  RM=1;
  for (int i=1; i <= m - 1; i++)   RM=(R * RM) % q;
  patHash=hash(pat,m);
}

public RabinKarp ( String pat ) { this . pat = pat ; R = 256 ; m = pat . length ( ) ; q = longRandomPrime ( ) ; RM = 1 ; for ( int i = 1 ; i <= m - 1 ; i ++ ) RM = ( R * RM ) % q ; patHash = hash ( pat , m ) ; }
preprocesses the pattern string .
