LambdaClass Profile picture
Jan 16 15 tweets 3 min read
(1/15) TRIES

Let’s dive into the world of data structures! Today, we’ll talk about Tries. Trie is used because it is the fastest for auto-complete suggestions. 🧵

#DataStructures #Lambdathread
(2/15) A trie (or prefix tree) is a tree-like data structure that is often used to store a collection of strings. Each node in the trie represents a character in a string, and the path from the root to a particular node represents a prefix of one of the strings in the collection.
(3/15) Its main advantages are related to efficient insertion, search, and deletion operations, as well as the ability to quickly find all strings that start with a particular prefix.
(4/15) And which are the common use cases for tries?

1- Autocomplete: Tries are often used to implement autocomplete functionality, where a user starts typing a word, and the system suggests possible completions for the word based on a pre-populated set of strings.
(5/15)
2- Spell checker: Tries can be used to quickly look up words in a dictionary to check the spelling of a document.

3- IP Routing: Trie can be used in IP routing tables for Longest Prefix Matching (LPM)
(6/15)
4- T9 predictive text: The T9 system uses a trie to predict the word a user is trying to type on a phone's keypad.

5- DNA Sequence analysis: Trie can be used to analyze the DNA sequence in Bioinformatics.
(7/15)
6- Network data compression: Trie can be used to compress network data like IP packets by looking up the longest matching prefix.
(8/15) Let's focus on one of the key advantages of using a trie: its ability to quickly retrieve information. Tries are particularly efficient when it comes to searching for a specific string in a collection of strings, or finding all strings that start with a particular prefix.
(9/15) This is because each character in a string is represented by a node in the trie, and the path from the root to a particular node represents a prefix of one of the strings in the collection.
(10/15) This allows for quick lookups by traversing down the tree from the root to the node that corresponds to the last character of the string or prefix being searched for.
(11/15) If the desired string or prefix is present in the trie, the search will terminate at the final node of the string or prefix.
(12/15) So… This makes tries particularly useful in cases where you need to perform many lookups or search for many different substrings quickly, and in cases where the number of strings being stored is large and the length of the strings is long.
(13/15) Tries may not appear to be practical for everyday situations as their main function is very specific: rapidly retrieve elements.
(14/15) While tries are an effective solution for certain types of problems, such as autocomplete or spell checking, they may not be as applicable to other types of problems where their specific functionality isn’t as useful.
(15/15) Their prime functionality is to retrieve specific strings or prefixes. However, its not the only one among tree-based data structures, other data structures like B-Trees and R-Trees also have specific use cases and strengths in different contexts.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with LambdaClass

LambdaClass Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @ClassLambda

Jan 11
ARRAYS VS. HASH MAPS

(1/12) As promised, we will continue with twitter threads about different concepts. Today we are going to explain the differences between ARRAYS and HASH MAPS, in both structures and uses. 👇🧵 Image
(2/12) What is the difference between arrays and hash maps? Arrays are faster for accessing an element at a specific position, and if you need to perform the same operation on all elements in the array, while hash maps are faster for looking up a value given a key.
(3/12) Arrays and hash maps are both data structures that are used to store and retrieve data. However, they differ in several ways:
▪️ Indexing
▪️ Search time
▪️ Insertion and deletion Image
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(