SlideShare une entreprise Scribd logo
1  sur  27
TRIES
AN EXCELLENT DATA
STRUCTURE FOR
STRINGS
Tries
 Instructor
Md. Shamsujjoha
Senior Lecturer
Department of CSE
East West University
 Presented by:
Md. Naim Khan
Id :2014-2-60-092
Md. Riad Khan
Id :2014-1-60-040
Slide
2
Overview
 History & Definition
 Types of Tries
Standard Tries
Compressed Tries
Suffix Tries
 Conclusion
Slide
3
History
 The term trie comes from retrieval.
 This term was coined by Edward Fredkin, who
pronounce it tri as in the word retrieval.
Slide
4
Definition of Tries
 A data structure for representing a collection of
strings.
 In computer science, a trie, also called digital tree
and sometimes radix tree or prefix tree.
Tries support fast pattern matching.
Slide
5
Properties of a tries
 A multi-way tree.
 Each node has from 1 to n children.
 Each edge of the tree is labeled with a character.
 Each leaf nodes corresponds to the stored string,
which is a concatenation of characters on a path
from the root to this node.
Slide
6
Standard Trie
 The standard trie for a set of strings S is an ordered
tree such that:
*Each node but the root is labeled with a character.
*The children of a node are alphabetically ordered.
*The paths from the external nodes to the root yield
the strings of S.
Slide
7
Standard Tries - Insertion
 Strings ={an, and, any, at}
n
a
d
t
y
Root
Slide
8
Example of Standard tries
 Example: Standard trie for the set of strings
S = { bear, bell, bid, bull, buy, sell, stock, stop }
te
s
uie
b
o
llla
d y
c
k
p
lllr
Root
Slide
9
Handling keys(strings)
 When a key(string) is a prefix of another key.
 How can we know that “an” is a word?
Example: an, and
n
a
d
t
y
Root
Slide
10
Handling keys(strings)
 We add a special termination symbol “$’’
 We append the “$’’ to each keyword
 Strings={ an, and, any, at}
n
a
d
t
y
Root
$
$ $
$
Slide
11
Standard Tries- Searching
 Search hit: Node where search ends has a $ symbol
 Search - sea
n
a
d
t
y
Root
a t
e
s
$
$$
$
$ $
Slide
12
Standard Tries- Deletion
 Three cases
Word not found…!
Word exists as a stand alone word.
Word exists as a prefix of another word
Slide
13
Standard Tries- Deletion
 Word not found
return false.
 Word exists as a stand alone word
part of any other word
does not a part of any other word
Slide
14
Standard Tries- Deletion
 Part of any other word
 Delete - sea
n
a
d
t
y
Root
a t
e
s
$
$$
$
$ $
Slide
15
Deleted
Standard Tries-Deletion
 Does not a part of any other word
 Delete - set
n
a
d
t
y
Root
t
e
s
$
$
$
$ $
Slide
16
Deleted
Standard Tries- Deletion
 Word exists as a prefix of any other word.
 Delete - an
n
a
d
t
y
Root
a t
e
s
$
$$
$
$ $
Slide
17
Deleted
Compressd Tries
 Tries with nodes of degree at least 2
 Obtained by standard tries by compressing
chains of redundant nodes
Slide
18
Compressed Trie- Example
 In order to understand Compressed Trie we need to
see the Standard Trie Example:
te
s
uie
b
o
llla
d y
c
k
p
lllr
Root
Standard Trie
Slide
19
Compressed Tries Example
 Compressed Tries:
 S = { bear, bell, bid, bull, buy, sell, stock, stop }
b
s
e u toid ell
llar ll y
ck p
Root Compressed Trie
Slide
20
Suffix Tries
 A suffix trie is a compressed trie for all the suffixes of
a text.
 Suffix trie are a space-efficient data structure to store
a string that allows many kinds of queries to be
answered quickly.
Slide
21
Example of Suffix Tries
 Let us consider an example text “soon$″.
Root
s
o
o
n
o
o
n
n
n
$
$
$
$
$
Slide
22
soon$
oon$
$
n$
on$
Done
 After alphabetically ordered the trie will look like
Root
s
o
o
n
o
o
n
n
n
$
$
$
$
$
Example of Suffix Tries
Understanding Requirements
 Insertion is faster as compared to the Hash Table
 Lookup is much more faster than Hash Table
implementations
 There are no collision of different keys in tries
Slide
23
References
Web pages
 http://www.mathcs.emory.edu/~cheung/Courses/323/Syll
abus/Text/trie01.html
 http://fbim.fh-
regensburg.de/~saj39122/sal/skript/progr/pr45102/Tries.p
df
 http://www.ideserve.co.in/learn/trie-delete
 http://algs4.cs.princeton.edu/lectures/52Tries.pdf
Book
 Data Structure and Algorithm
by Alfred V. Aho
Jeffery D. Ullman
John E.HopcroftJohn
Slide
24
Questions or Suggestions
Slide
25
Thank you
Slide
26
Inquiry
riadmrk.khan@gmail.com
naim1248@gmail.com

Contenu connexe

Tendances

Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 
Red black tree
Red black treeRed black tree
Red black treeRajendran
 
Linked stacks and queues
Linked stacks and queuesLinked stacks and queues
Linked stacks and queuesRamzi Alqrainy
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search TreeZafar Ayub
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTUREArchie Jamwal
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - GraphMadhu Bala
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First SearchKevin Jadiya
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design) Tasif Tanzim
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentationMuhammad Bilal Khan
 

Tendances (20)

Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Floyd Warshall Algorithm
Floyd Warshall AlgorithmFloyd Warshall Algorithm
Floyd Warshall Algorithm
 
Red black tree
Red black treeRed black tree
Red black tree
 
Linked stacks and queues
Linked stacks and queuesLinked stacks and queues
Linked stacks and queues
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Binary search
Binary searchBinary search
Binary search
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Splay Tree
Splay TreeSplay Tree
Splay Tree
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
B+tree Data structures presentation
B+tree Data structures presentationB+tree Data structures presentation
B+tree Data structures presentation
 
B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 

En vedette (20)

Application of tries
Application of triesApplication of tries
Application of tries
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
 
Tries - Tree Based Structures for Strings
Tries - Tree Based Structures for StringsTries - Tree Based Structures for Strings
Tries - Tree Based Structures for Strings
 
TRIES_data_structure
TRIES_data_structureTRIES_data_structure
TRIES_data_structure
 
Trie (1)
Trie (1)Trie (1)
Trie (1)
 
Trie tree
Trie treeTrie tree
Trie tree
 
Lec18
Lec18Lec18
Lec18
 
Interactive High-Dimensional Visualization of Social Graphs
Interactive High-Dimensional Visualization of Social GraphsInteractive High-Dimensional Visualization of Social Graphs
Interactive High-Dimensional Visualization of Social Graphs
 
Introduction of suffix tree
Introduction of suffix treeIntroduction of suffix tree
Introduction of suffix tree
 
Multi way&btree
Multi way&btreeMulti way&btree
Multi way&btree
 
Packet forwarding in wan.46
Packet  forwarding in wan.46Packet  forwarding in wan.46
Packet forwarding in wan.46
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix Array
 
Application of hashing in better alg design tanmay
Application of hashing in better alg design tanmayApplication of hashing in better alg design tanmay
Application of hashing in better alg design tanmay
 
Introduction to statistics ii
Introduction to statistics iiIntroduction to statistics ii
Introduction to statistics ii
 
Geo webinarjune2015
Geo webinarjune2015Geo webinarjune2015
Geo webinarjune2015
 
R-Trees and Geospatial Data Structures
R-Trees and Geospatial Data StructuresR-Trees and Geospatial Data Structures
R-Trees and Geospatial Data Structures
 
B tree long
B tree longB tree long
B tree long
 
Fundamentals
FundamentalsFundamentals
Fundamentals
 
Basic Packet Forwarding in NS2
Basic Packet Forwarding in NS2Basic Packet Forwarding in NS2
Basic Packet Forwarding in NS2
 
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
 

Dernier

Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Dernier (20)

Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

Data structure tries

  • 2. Tries  Instructor Md. Shamsujjoha Senior Lecturer Department of CSE East West University  Presented by: Md. Naim Khan Id :2014-2-60-092 Md. Riad Khan Id :2014-1-60-040 Slide 2
  • 3. Overview  History & Definition  Types of Tries Standard Tries Compressed Tries Suffix Tries  Conclusion Slide 3
  • 4. History  The term trie comes from retrieval.  This term was coined by Edward Fredkin, who pronounce it tri as in the word retrieval. Slide 4
  • 5. Definition of Tries  A data structure for representing a collection of strings.  In computer science, a trie, also called digital tree and sometimes radix tree or prefix tree. Tries support fast pattern matching. Slide 5
  • 6. Properties of a tries  A multi-way tree.  Each node has from 1 to n children.  Each edge of the tree is labeled with a character.  Each leaf nodes corresponds to the stored string, which is a concatenation of characters on a path from the root to this node. Slide 6
  • 7. Standard Trie  The standard trie for a set of strings S is an ordered tree such that: *Each node but the root is labeled with a character. *The children of a node are alphabetically ordered. *The paths from the external nodes to the root yield the strings of S. Slide 7
  • 8. Standard Tries - Insertion  Strings ={an, and, any, at} n a d t y Root Slide 8
  • 9. Example of Standard tries  Example: Standard trie for the set of strings S = { bear, bell, bid, bull, buy, sell, stock, stop } te s uie b o llla d y c k p lllr Root Slide 9
  • 10. Handling keys(strings)  When a key(string) is a prefix of another key.  How can we know that “an” is a word? Example: an, and n a d t y Root Slide 10
  • 11. Handling keys(strings)  We add a special termination symbol “$’’  We append the “$’’ to each keyword  Strings={ an, and, any, at} n a d t y Root $ $ $ $ Slide 11
  • 12. Standard Tries- Searching  Search hit: Node where search ends has a $ symbol  Search - sea n a d t y Root a t e s $ $$ $ $ $ Slide 12
  • 13. Standard Tries- Deletion  Three cases Word not found…! Word exists as a stand alone word. Word exists as a prefix of another word Slide 13
  • 14. Standard Tries- Deletion  Word not found return false.  Word exists as a stand alone word part of any other word does not a part of any other word Slide 14
  • 15. Standard Tries- Deletion  Part of any other word  Delete - sea n a d t y Root a t e s $ $$ $ $ $ Slide 15 Deleted
  • 16. Standard Tries-Deletion  Does not a part of any other word  Delete - set n a d t y Root t e s $ $ $ $ $ Slide 16 Deleted
  • 17. Standard Tries- Deletion  Word exists as a prefix of any other word.  Delete - an n a d t y Root a t e s $ $$ $ $ $ Slide 17 Deleted
  • 18. Compressd Tries  Tries with nodes of degree at least 2  Obtained by standard tries by compressing chains of redundant nodes Slide 18
  • 19. Compressed Trie- Example  In order to understand Compressed Trie we need to see the Standard Trie Example: te s uie b o llla d y c k p lllr Root Standard Trie Slide 19
  • 20. Compressed Tries Example  Compressed Tries:  S = { bear, bell, bid, bull, buy, sell, stock, stop } b s e u toid ell llar ll y ck p Root Compressed Trie Slide 20
  • 21. Suffix Tries  A suffix trie is a compressed trie for all the suffixes of a text.  Suffix trie are a space-efficient data structure to store a string that allows many kinds of queries to be answered quickly. Slide 21
  • 22. Example of Suffix Tries  Let us consider an example text “soon$″. Root s o o n o o n n n $ $ $ $ $ Slide 22 soon$ oon$ $ n$ on$ Done
  • 23.  After alphabetically ordered the trie will look like Root s o o n o o n n n $ $ $ $ $ Example of Suffix Tries
  • 24. Understanding Requirements  Insertion is faster as compared to the Hash Table  Lookup is much more faster than Hash Table implementations  There are no collision of different keys in tries Slide 23
  • 25. References Web pages  http://www.mathcs.emory.edu/~cheung/Courses/323/Syll abus/Text/trie01.html  http://fbim.fh- regensburg.de/~saj39122/sal/skript/progr/pr45102/Tries.p df  http://www.ideserve.co.in/learn/trie-delete  http://algs4.cs.princeton.edu/lectures/52Tries.pdf Book  Data Structure and Algorithm by Alfred V. Aho Jeffery D. Ullman John E.HopcroftJohn Slide 24