MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / HashFunction

Method HashFunction

RabinKarp.java:51–67  ·  view source on GitHub ↗
(String inp, int alphabets)

Source from the content-addressed store, hash-verified

49 }
50
51 public static int HashFunction(String inp, int alphabets)
52 {
53 int k=inp.length()-1;
54
55 int res=0;
56
57 for(int i=0;i<inp.length();i++)
58 {
59 int asc = inp.charAt(i);
60
61 res = res + (asc*(int)Math.pow(alphabets,k));
62
63 k--;
64 }
65
66 return res;
67 }
68}

Callers 1

rabinKarpMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected