SlideShare a Scribd company logo
1 of 19
TRIE
By
Vinay Kulkarni
Shrikrishna Warkhedi
Scope
•Standard Trie
•Compressed Trie
TRIE
•DIGITAL TREE / RADIX TREE / PREFIX TREE.
•The name trie comes from its use for
retrieval
• you can pronounce it as TRY or TREE both
are acceptable
Why tries ?
•We have seen that preprocessing the pattern
speeds up pattern matching queries .
•If the text is large, immutable and searched for
often ,we may want to preprocess the text instead
of the pattern in order to perform pattern
matching queries in time proportional to the
pattern length.
Standard Tries
The standard trie for a set of strings S is an
ordered tree such that:
1.each node but the root is labeled with a
character
2.the children of a node are alphabetically
ordered
3.the paths from the external nodes to the
root yield the strings of S
Example: standard trie for the set of strings
S = { bear, bell, bid, bull,
buy, sell, stock, stop }
•A standard trie uses O(n) space and supports
searches, insertions and deletions in time
O(dm), where:
n total size of the strings in S
m size of the string parameter of the
operation
d size of the alphabet
Application
•A common application of a trie is storing
a predictive text or autocomplete dictionary,
such as found on a mobile telephone. Such
applications take advantage of a trie's ability
to quickly search for, insert, and delete
entries
Compressed Tries:
• A compressed trie is like a standard trie but makes sure that each trie
had a degree of at least 2. Single child nodes are compressed into a
single edge.
• It is obtained from standard trie by compressing chains of “redundant”
nodes
Standard TRIES
Compressed TRIES
Compact Representation Of Compressed
Tries:
• Compact representation of a compressed trie for an array of strings:
• Stores at the nodes ranges of indices instead of substrings
• Uses O(s) space, where s is the number of strings in the array
• Serves as an auxiliary index structure
Insertion And Deletion in Compressed TRIE
Compression TRIES Algorithm:
• Replace:
• a redundant chain or edges (v0,v1), (v1,v2), ..., (vk−1,vk)
• by one edge:
• (v0 ,vk)
• Replace:
• the label vk
• by the label:
• v v2....vk
• Each internal node in a compressed tire has at least two children
and each external is associated with a string. The compression
reduces the total space for the trie from O(m) where m is the sum
of the the lengths of strings in S to O(n) where n is the number of
strings in S.
Applications:
• Tries are usually static i.e. insertion and deletion are disabled.
• Therefore they are used in compression of the already available
data.
• This application is typically used for compressing lookup tables
when the total set of stored keys is very sparse within their
representation space.
• It is also typically used in the implementation of the various
fast lookup tables needed to retrieve Unicode character
properties (for example to represent case mapping tables, or
lookup tables containing the combination of base and combining
characters needed to support Unicode normalization

More Related Content

What's hot

What's hot (20)

2. bit fields union enum
2. bit fields  union  enum2. bit fields  union  enum
2. bit fields union enum
 
Java
JavaJava
Java
 
Array
ArrayArray
Array
 
Chap 7(array)
Chap 7(array)Chap 7(array)
Chap 7(array)
 
Data structure tries
Data structure triesData structure tries
Data structure tries
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Huffman coding01
Huffman coding01Huffman coding01
Huffman coding01
 
Array
ArrayArray
Array
 
Array
ArrayArray
Array
 
7.basic array
7.basic array7.basic array
7.basic array
 
Huffman analysis
Huffman analysisHuffman analysis
Huffman analysis
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
t-vMF Similarity
t-vMF Similarityt-vMF Similarity
t-vMF Similarity
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Lect9
Lect9Lect9
Lect9
 
Huff
HuffHuff
Huff
 
Java part 2
Java part  2Java part  2
Java part 2
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
Data Representation of Strings
Data Representation of StringsData Representation of Strings
Data Representation of Strings
 

Similar to Trie (1)

29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn
29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn
29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn
ratnapatil14
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
Tri Truong
 
Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013
Ben Brumfield
 
Set Similarity Search using a Distributed Prefix Tree Index
Set Similarity Search using a Distributed Prefix Tree IndexSet Similarity Search using a Distributed Prefix Tree Index
Set Similarity Search using a Distributed Prefix Tree Index
HPCC Systems
 
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Tutun Juhana
 

Similar to Trie (1) (20)

Tries .ppt
Tries .pptTries .ppt
Tries .ppt
 
Lecture10.pdf
Lecture10.pdfLecture10.pdf
Lecture10.pdf
 
presentation on important DAG,TRIE,Hashing.pptx
presentation on important DAG,TRIE,Hashing.pptxpresentation on important DAG,TRIE,Hashing.pptx
presentation on important DAG,TRIE,Hashing.pptx
 
Basics of Python
Basics of PythonBasics of Python
Basics of Python
 
Graph Algorithms
Graph AlgorithmsGraph Algorithms
Graph Algorithms
 
29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn
29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn
29_Tries.ppt nnnnnnnnnnnnnnnnnnnnnnnnnnn
 
String.pptx
String.pptxString.pptx
String.pptx
 
Information and data security advanced encryption standard (aes)
Information and data security advanced encryption standard (aes)Information and data security advanced encryption standard (aes)
Information and data security advanced encryption standard (aes)
 
Data Structures 5
Data Structures 5Data Structures 5
Data Structures 5
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
 
Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013Introduction to Regular Expressions RootsTech 2013
Introduction to Regular Expressions RootsTech 2013
 
Unit VI - Graphs.ppt
Unit VI - Graphs.pptUnit VI - Graphs.ppt
Unit VI - Graphs.ppt
 
Graph 2
Graph 2Graph 2
Graph 2
 
Set Similarity Search using a Distributed Prefix Tree Index
Set Similarity Search using a Distributed Prefix Tree IndexSet Similarity Search using a Distributed Prefix Tree Index
Set Similarity Search using a Distributed Prefix Tree Index
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Bioinformatica p2-p3-introduction
Bioinformatica p2-p3-introductionBioinformatica p2-p3-introduction
Bioinformatica p2-p3-introduction
 
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)Et3003 sem2-1314-4 network layers i (ipv4 addressing)
Et3003 sem2-1314-4 network layers i (ipv4 addressing)
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
 
B tree ,B plus and graph
B tree ,B plus and graph B tree ,B plus and graph
B tree ,B plus and graph
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Trie (1)

  • 3. TRIE •DIGITAL TREE / RADIX TREE / PREFIX TREE. •The name trie comes from its use for retrieval • you can pronounce it as TRY or TREE both are acceptable
  • 4. Why tries ? •We have seen that preprocessing the pattern speeds up pattern matching queries . •If the text is large, immutable and searched for often ,we may want to preprocess the text instead of the pattern in order to perform pattern matching queries in time proportional to the pattern length.
  • 5. Standard Tries The standard trie for a set of strings S is an ordered tree such that: 1.each node but the root is labeled with a character 2.the children of a node are alphabetically ordered 3.the paths from the external nodes to the root yield the strings of S Example: standard trie for the set of strings S = { bear, bell, bid, bull, buy, sell, stock, stop }
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. •A standard trie uses O(n) space and supports searches, insertions and deletions in time O(dm), where: n total size of the strings in S m size of the string parameter of the operation d size of the alphabet
  • 11. Application •A common application of a trie is storing a predictive text or autocomplete dictionary, such as found on a mobile telephone. Such applications take advantage of a trie's ability to quickly search for, insert, and delete entries
  • 12. Compressed Tries: • A compressed trie is like a standard trie but makes sure that each trie had a degree of at least 2. Single child nodes are compressed into a single edge. • It is obtained from standard trie by compressing chains of “redundant” nodes
  • 14. Compact Representation Of Compressed Tries: • Compact representation of a compressed trie for an array of strings: • Stores at the nodes ranges of indices instead of substrings • Uses O(s) space, where s is the number of strings in the array • Serves as an auxiliary index structure
  • 15.
  • 16. Insertion And Deletion in Compressed TRIE
  • 17. Compression TRIES Algorithm: • Replace: • a redundant chain or edges (v0,v1), (v1,v2), ..., (vk−1,vk) • by one edge: • (v0 ,vk) • Replace: • the label vk • by the label: • v v2....vk
  • 18. • Each internal node in a compressed tire has at least two children and each external is associated with a string. The compression reduces the total space for the trie from O(m) where m is the sum of the the lengths of strings in S to O(n) where n is the number of strings in S.
  • 19. Applications: • Tries are usually static i.e. insertion and deletion are disabled. • Therefore they are used in compression of the already available data. • This application is typically used for compressing lookup tables when the total set of stored keys is very sparse within their representation space. • It is also typically used in the implementation of the various fast lookup tables needed to retrieve Unicode character properties (for example to represent case mapping tables, or lookup tables containing the combination of base and combining characters needed to support Unicode normalization