MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / createLPS

Method createLPS

Programs/KMP.java:40–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39
40 private void createLPS() {
41 int i=0,j=1;
42 this.lps[0] = 0;
43
44 while(j<this.pattern.length()) {
45 if(this.pattern.charAt(i) == this.pattern.charAt(j)) {
46 this.lps[j] = i+1;
47 i++;
48 j++;
49 }
50 else if(i ==0) { //this is same as because we wont reach this part if they are not equal, this.pattern.charAt(i) != this.pattern.charAt(j) && i ==0
51 this.lps[j] = 0;
52 j++;
53 }
54 else {
55 i = this.lps[i-1];
56 }
57 }
58 }
59}
60public class Main{
61 public static void main(String args[]) {

Callers 1

kmpMethod · 0.95

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected