Code Monkey home page Code Monkey logo

ukkonen-suffixtree's Introduction

Implementation of Ukkonen's algorithm in C++. This is very special algorithm. You may have a look at the original paper here: http://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf.

Do |make| to compile and |make run| to execute.

Output would be all the edges in the suffix tree with the following details: StartNode Endnode SuffixlinkOfEndNode StartLabelIndex EndLabelIndex String

where: StartLabelIndex is the starting index of the substring represented by this edge. EndLabelIndex is the ending index of the substring represented by this edge. String is the full label represented by this edge.

Alphabet set is unlimited.

To get the explicit suffix tree you have to end the input string with a unique character.

You can do a search in the suffix tree for any substring.

This is a linear time algorithm.

Only significant data structure that I've used is a hash table. This implementaion of hash table has an constant average case complexity.

ukkonen-suffixtree's People

Contributors

atuljangra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ukkonen-suffixtree's Issues

Some thing went wrong

Hi, when enter a string: vbxkabcabx, your code returns 10 edges which is actually not enough.

Enter String
vbxkabcabx
StartNode	EndNode	SuffixLink	FirstIndex	lastIndex	String
9		10		0		9		9		x
0		9		6		4		5		ab
0		8		0		6		9		cabx
6		7		0		6		9		cabx
0		1		0		0		9		vbxkabcabx
6		2		0		2		9		xkabcabx
0		3		0		2		9		xkabcabx
0		4		0		3		9		kabcabx
9		5		0		6		9		cabx
0		6		0		1		1		b
Total edges: 10

I think you missed the edge (String = x) from node number 6 (the edge from node 6 to node 2 should be divided into two parts). The same should apply for edge from node 0 and 3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.