Coder Social home page Coder Social logo

shinchancode / trie-data-structure Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 167 KB

Trie is a tree-based data structure, which is used for efficient retrieval of a key in a large dataset of strings.

C++ 100.00%
binary-search-tree data-structures-and-algorithms efficient-searching hashing key-length project resume search-algorithm spell-check spell-checker

trie-data-structure's Introduction

Trie-Data-structure

Trie is a tree-based data structure, which is used for efficient retrieval of a key in a large dataset of strings.

It is a type of k-ary search tree used for storing and searching a specific key from a set. Using Trie, search complexities can be brought to optimal limit (key length).

Trie Data

Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.

Comparison with Binary Search Tree

If we store keys in a binary search tree, a well balanced BST will need time proportional to M * log N, where M is the maximum string length and N is the number of keys in the tree.

Trie is an efficient information retrieval data structure. Using Trie, search complexities can be brought to optimal limit O(M) (Where M is the maximum string length).


The idea is that all strings sharing common prefix should come from a common node. The tries are used in spell checking programs.

  • Preprocessing pattern improves the performance of pattern matching algorithm. But if a text is very large then it is better to preprocess text instead of pattern for efficient search.
  • A trie is a data structure that supports pattern matching queries in time proportional to the pattern size.

[Basic Implementation]


Do star โญ this Repository if you feel it helped & drop a follow!

๐Ÿ’™ Happy Learning ๐Ÿ’™

Demo || Working

Open the folder to view the working and output..

Usage

Create a Trie with:

Trie *t = new Trie();

Add Keys with:

// i.e. you could store any information you would like to associate with
// this particular key.
t->insert(name, num);

Find a key with:

bool ok = t->search(s);

Remove Keys with:

t->remove(name);

Search with:

t->search(s);

Prefix search with:

t->starts_with(s);

Prefix search with recommendations:

t->show_recommendations(name);

Contributing

Fork this repo and run tests with:

Connect with me:

codeSTACKr.com codeSTACKr | Twitter codeSTACKr | LinkedIn codeSTACKr | Instagram


trie-data-structure's People

Contributors

shinchancode avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

rishurai2001

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.