Giter VIP home page Giter VIP logo

trie's Introduction

Trie

A trie implementation in Java with the following features:

  • finds words that start with the given prefix;

  • finds all words occurring in a given pattern from left to right;

    e.g: given the pattern "wverticall" the words found will be "vertical", "call" and "all";

  • finds all the valid words from the permutation of the given letters;

    e.g: given the letters "a e r d" the words found will be "dare","dear","are","rad","red","read","ear" and "era";

  • finds all the words that fit in the given string expression according to the wildcards' position;

    e.g: given the expression "s??ce", where the symbol ? is the wildcard, the words found will be "slice", "space", "since", ecc ...

Useful for finding anagrams and words.

A faster and lighter implementation is given by this DoubleArrayTrie

Usage

Create and populate the Trie

Trie trie = new Trie();
for(String word : myDictionary) {
  trie.insert(word);
}

Only for the match method you need to call first the buildSuffixLinks method

trie.buildSuffixLinks();
ArrayList<String> words = trie.match("wverticall");

ToDo

  • Improve performance of permute and query methods by making them from recursive to iterative
  • Write own writeObject and readObject methods to speed up serialization and reduce the risk of StackOverflow

trie's People

Contributors

automatik avatar

Watchers

 avatar

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.