random thoughts

cat /dev/random > ideas

Suffix Tree

| Comments

generalized suffix tree
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <vector>
using namespace std;
struct node
{
	node *suffix;
};
struct edge
{
	string label;
	node *dest_node;
};
class generalized_suffix_tree
{
public:
	generalized_suffix_tree() : last_index(0), root(0), last_leaf(0) {}
	vector<int> search(const string& word);

private:
	node *search_node(const string &word);
	int last_index;
	node *root;
	node *last_leaf;

};

Follow-ups and references

  1. Suffix array is a depth-first traversal result of a suffix tree
  2. LCP array longest common prefix array

Comments