In this post - Suffix Trees: Java Code as Separate Classes.
Download java source code.
Please refer previous posts about Suffix Trees:
Class diagram:
contains and indexOf functions:
Future plans:
More information about Suffix Trees Use Cases you can find in:
Download java source code.
Please refer previous posts about Suffix Trees:
Class diagram:
contains and indexOf functions:
public boolean contains(String str) { return indexOf(str) >= 0; } public int indexOf(String str) { if (str.length() == 0) return -1; int index = -1; Node node = root; int i = 0; while (i<str.length()) { if ((node == null) || (i == text.length())) return -1; Edge edge = node.findEdge(str.charAt(i)); if (edge == null) return -1; index = edge.getBeginIndex()-i; i++; for(int j=edge.getBeginIndex()+1; j<=edge.getEndIndex(); j++) { if (i == str.length()) break; if (text.charAt(j) != str.charAt(i)) return -1; i++; } node = edge.getEndNode(); } return index; }
Future plans:
- Generalized Suffix Tree;
- Longest Common SubString;
More information about Suffix Trees Use Cases you can find in: