Questions tagged [suffix-tree]

A suffix tree is a data structure that stores all suffixes of a string. It is the basis for many fast algorithms on strings.

228 questions
3
votes
3 answers

Complete Suffix Array

A suffix array will index all the suffixes for a given list of strings, but what if you're trying to index all the possible unique substrings? I'm a bit new at this, so here's an example of what I mean: Given the string abcd A suffix array indexes…
Arjun
  • 1,701
  • 4
  • 17
  • 25
3
votes
2 answers

Conceptually simple linear-time suffix tree constructions

In 1973 Weiner gave the first linear-time construction of suffix trees. The algorithm was simplified in 1976 by McCreight, and in 1995 by Ukkonen. Nevertheless, I find Ukkonen's algorithm relatively involved conceptually. Has there been…
Randomblue
  • 112,777
  • 145
  • 353
  • 547
3
votes
2 answers

Clarification regarding Ukkonen's Suffix Tree

I have been reading up on Ukkonen's Suffix tree for my work and wanted to confirm if the following is true. Would it be correct to say that in a Ukkonen Suffix Tree: Only edges that lead to leaf nodes can have multiple consecutive characters…
Hari
  • 5,057
  • 9
  • 41
  • 51
3
votes
5 answers

Match and replace emoticons in string - what is the most efficient way?

Wikipedia defines a lot of possible emoticons people can use. I want to match this list to words in a string. I now have this: $string = "Lorem ipsum :-) dolor :-| samet"; $emoticons = array( '[HAPPY]' => array(' :-) ', ' :) ', ' :o) '), //etc... …
Pr0no
  • 3,910
  • 21
  • 74
  • 121
3
votes
2 answers

substring searching in a string using suffix tree..?

I have read that : Searching for a substring, pat[1..m], in txt[1..n], can be solved in O(m) time (after the suffix tree for txt has been built in O(n) time). but at each point, we will have to choose which branch to take, so like in n-ary tree, at…
xyz
  • 8,607
  • 16
  • 66
  • 90
3
votes
0 answers

How to properly unit test a suffix tree algorithm?

I'm working on an implementation of Ukkonen's linear time suffix tree construction algorithm, and planning to implement improvements suggested by e.g. Kurtz and NJ Larsson (for example edge links instead of suffix links). While testing, I…
Leaky
  • 3,088
  • 2
  • 26
  • 35
3
votes
2 answers

C++ Default Argument with Pointers

I am writing a program which implements a suffix trie in C++. I am trying to declare a recursive function with no parameters, but which needs to pass a pointer to itself. I am defining it thus public: string longestRepeat(Node*); in the header…
Luke Collins
  • 1,433
  • 3
  • 18
  • 36
3
votes
1 answer

Accessing the first Character of a String with no Characters

I am implementing a suffix trie in C++. The implementation of the Trie contructor can be seen below. #include #include #include "Trie.hpp" using namespace std; Trie::Trie(string T){ T += "#"; …
Luke Collins
  • 1,433
  • 3
  • 18
  • 36
3
votes
3 answers

Building a suffix tree by inserting each suffix in Haskell

I am working with the following data type: data SuffixTree = Leaf Int | Node [(String, SuffixTree)] deriving (Eq, Show) Each subtree has a corresponding label (string). The idea is to build the corresponding suffix tree by adding…
David
  • 447
  • 3
  • 15
3
votes
1 answer

Longest maximum repeating substring

A substring can be of length 1,2,3... The question that I was trying to solve involved finding the substring that occurred the maximum number of times. So it basically broke down to finding the character having the maximum frequency. However, I…
Anand Zutshi
  • 125
  • 1
  • 3
  • 11
3
votes
1 answer

Finding all names matching a query: how to use a suffix tree?

Question : You have a smartphone and you opened the contact app. You want to search a contact. let's say manmohan. but you don't remember his full name. you only remember mohan so you started typing. the moment you type 'm' contact app will start…
Cereal_Killer
  • 304
  • 2
  • 13
3
votes
1 answer

Ukkonen's suffix tree algorithm: procedure 'test and split' unclear

ukkonen's on line construction algorithm i got a problem trying to understand the 'test and split' procedure,which is as follows: procedure test–and–split(s, (k, p), t): >1. if k ≤ p then >2. let g'(s,(k',p'))=s' be the tk-transition from s >3. if…
3
votes
1 answer

naive suffix tree implementation in Java

I am trying to write suffix tree class with a naive building algorithm which is O(m^2) and not Ukkonen. My doubt is regarding how to represent the tree. So far, I have got this. But I do not think that is the write class structure for nodes and…
Andy897
  • 6,915
  • 11
  • 51
  • 86
3
votes
1 answer

Building a suffix tree in C++

I'm attempting to build a suffix tree in C++ as part of an assignment on gene sequencing void Tree::insert(string ins) { Node* iterator = chooseBranch(root, ins.at(0)); string temp; for(int i=0; i<100; i++) { …
Jesse Welch
  • 63
  • 2
  • 6
3
votes
1 answer

What is considered the best Java Suffix Tree implementation?

I need a suffix tree Java Implementation. After some googling I concluded that the libdivsufsort C implementation is the best one around. Is there a Java implementation of the same (or almost as good) quality and that is preferably open source. The…
Koen Peters
  • 12,798
  • 6
  • 36
  • 59