mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
Format code with prettier (#3375)
This commit is contained in:
@@ -13,7 +13,6 @@ public class StringMatchFiniteAutomata {
|
||||
public static Scanner scanner = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
scanner = new Scanner(System.in);
|
||||
System.out.println("Enter String");
|
||||
String text = scanner.nextLine();
|
||||
@@ -26,7 +25,6 @@ public class StringMatchFiniteAutomata {
|
||||
}
|
||||
|
||||
public static void searchPat(String text, String pat) {
|
||||
|
||||
int m = pat.length();
|
||||
int n = text.length();
|
||||
|
||||
@@ -46,7 +44,6 @@ public class StringMatchFiniteAutomata {
|
||||
|
||||
// Computes finite automata for the partern
|
||||
public static void computeFA(String pat, int m, int[][] FA) {
|
||||
|
||||
for (int state = 0; state <= m; ++state) {
|
||||
for (int x = 0; x < CHARS; ++x) {
|
||||
FA[state][x] = getNextState(pat, m, state, x);
|
||||
@@ -55,7 +52,6 @@ public class StringMatchFiniteAutomata {
|
||||
}
|
||||
|
||||
public static int getNextState(String pat, int m, int state, int x) {
|
||||
|
||||
// if current state is less than length of pattern
|
||||
// and input character of pattern matches the character in the alphabet
|
||||
// then automata goes to next state
|
||||
@@ -64,11 +60,8 @@ public class StringMatchFiniteAutomata {
|
||||
}
|
||||
|
||||
for (int ns = state; ns > 0; ns--) {
|
||||
|
||||
if (pat.charAt(ns - 1) == x) {
|
||||
|
||||
for (int i = 0; i < ns - 1; i++) {
|
||||
|
||||
if (pat.charAt(i) != pat.charAt(state - ns + i + 1)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user