SlideShare une entreprise Scribd logo
1  sur  38
APPLICATION OF TRIES
Why Trie Data Structure?
• Searching trees in general favor keys which are of
 fixed size since this leads to efficient storage
 management.
• However in case of applications which are retrieval
 based and which call for keys varying length, tries
 provide better options.
• Tries are also called as Lexicographic Search
 trees.
Definition For Trie:
• A trie of order m may be empty.
• If not empty, then it consists of an ordered
 sequence of exactly m tries of order m.
• The branching at any level of the trie is
 determined only by the portion and not by the
 whole word.
• Alphabetic keys require a trie of order 27(26 letters
 of the alphabet + a blank) for their storage and
Representation Of Trie
• The trie have two category of node structures.
       ▫ Branch node
       ▫ Information node

• A branch node is merely a collection of LINK fields
 each pointing either to a branch node or to an
 information node.
• An information node holds the keys that is to be
 stored in the trie.
Operations In Trie
• The three operations in the trie data Structure
 are
                 • Searching a trie
                    • Insertion
                    • Deletion
Example

• Construct a Trie for the keys
001,100,111,011,010
STEP 1:
Insert (001,100)
               0        1



               001     100
Example
• STEP 2:       0       1
Insert(111)

                    0        1
              001




                    100     111
Example
• STEP 3:
Insert(011)         0     1


              0     1     0         1



              001   011       100       111
Example
• STEP 4:
Insert(010)                   0               1

              0           1             0         1



              001                       100       111


                    010           011
INSERTION
• To Insert a key K into the trie we begin as we
 would to search for the key k, possibly moving
 down the trie.
• At the point where the LINK field of the branch
 node leads to NIL, the key k is inserted as an
 information node.
Insertion
• In the Above constructed trie INSERT A KEY
  101.                                 0     1


           0           1         0     1




           001                               111


                 010       011   100   101
Deletion
• The deletion of a key K from a trie proceeds as one
  would to search for the key.
• On reaching the information node(node l)holding k, the
  same is deleted.
  ▫ It need to be ensured the branch node to which node l
    is linked accommodates other information node as well!
      If there is more than1 information node/if there is at
       least one LINK field/or both ,then deletion id done.
      If it leaves the branch node with just one more key
       ,we delete the branch node and push the node to a
       higher level
      If the situation leads to node being the only non
       empty node , once again we delete the branch node
       and push node to a higher level.
Deletion
• Delete 010:         0         1


          0       1             0           1



          001                                   111



                010       011   100   101
Performance Of trie
• The performance of search trees is determined by the
 number of keys that form the tree.
• The complexities of the search ,delete and insert
 operations were given by O(h) where the height h is
 dependent on the number of keys represented in the
 search tree.
• In contrast, the performance of the trie is dependent on
 the length of the key-The number of characters forming
 the key rather than the number of keys itself.
APPLICATIONS OF TRIE DATA
       STRUCTURES
TRIES IN AUTO COMPLETE
• Since a trie is a tree-like data structure in which each
  node contains an array of pointers, one pointer for each
  character in the alphabet.
• Starting at the root node, we can trace a word by
  following pointers corresponding to the letters in the
  target word.
• Starting from the root node, you can check if a word
  exists in the trie easily by following pointers
  corresponding to the letters in the target word.
AUTO COMPLETE
• Auto-complete functionality is used widely over
 the internet and mobile apps. A lot of websites
 and apps try to complete your input as soon as
 you start typing.
• All the descendants of a node have a common
 prefix of the string associated with that node.
AUTO COMPLETE IN GOOGLE SEARCH
WHY TRIES IN AUTO COMPLETE
• Implementing auto complete using a trie is easy.
• We simply trace pointers to get to a node that
 represents the string the user entered. By
 exploring the trie from that node down, we can
 enumerate all strings that complete user’s input.
CRIMINOLOGY
• Suppose that you are at the scene of a crime and
 observe the first few characters CRX on the
 registration plate of the getaway car. If we have a
 trie of registration numbers, we can use the
 characters CRX to reach a subtrie that contains all
 registration numbers that begin with CRX. The
 elements in this subtrie can then be examined to
 see which cars satisfy other properties that might
 have been observed.
AUTOMATIC COMMAND COMPLETION

• When using an operating system such as Unix or
 DOS, we type in system commands to accomplish
 certain tasks. For example, the Unix and DOS
 command cd may be used to change the current
 directory.
Commands that have the prefix “ps”
•   ps2ascii    ps2pdf  psbook       psmandup     psselect
•   ps2epsi     ps2pk   pscal      psmerge     pstopnm
•   ps2frag     ps2ps   psidtopgm     psnup     pstops
•   ps2gif     psbb    pslatex    psresize   pstruct
•   Figure 10 Commands that begin with "ps"

    We can simply the task of typing in commands by providing a command
    completion facility which automatically types in the command suffix once the
    user has typed in a long enough prefix to uniquely identify the command.
    For instance, once the letters psi have been entered, we know that the
    command must be psidtopgm because there is only one command that has
    the prefix psi. In this case, we replace the need to type in a 9 character
    command name by the need to type in just the first 3 characters of the
    command!
LONGEST PREFIX MATCHING
• Longest prefix match (also called Maximum prefix length match)
  refers to an algorithm used by routers in Internet Protocol (IP)
  networking to select an entry from a routing table .
• Because each entry in a routing table may specify a network, one
  destination address may match more than one routing table entry.
  The most specific table entry — the one with the highest subnet
  mask — is called the longest prefix match. It is called this because it
  is also the entry where the largest number of leading address bits in
  the table entry match those of the destination address.
For example, consider this IPv4 routing table (CIDR
 notation is used):
192.168.20.16/28
192.168.0.0/16


When the address 192.168.20.19 needs to be looked
 up, both entries in the routing table "match". That is, both
 entries contain the looked up address. In this case, the
 longest prefix of the candidate routes is
 192.168.20.16/28, since its subnet mask (/28) is higher
 than the other entry's mask (/16), making the route more
 specific.
• A network browser keeps a history of the URLs of
 sites that you have visited. By organizing this history
 as a trie, the user need only type the prefix of a
 previously used URL and the browser can complete
 the URL.
SPELL CHECKERS

• Spell checkers are ubiquitous. Word
  processors have spell checkers, as
  do browser-based e-mail clients.
  They all work the same way: a
  dictionary is stored in some data
  structure, then each word of input is
  submitted to a search in the data
  structure, and those that fail are
  flagged as spelling errors
SPELL CHECKERS

• There are many appropriate data structures to
 store the word list, including a sorted array
 accessed via binary search, a hash table, or a
 bloom filter. In this exercise you are challenged
 to store the word list character-by-character in a
 trie.
Spell Check..
Spell Check..
    a    bc…           0 p       …z
0
                   a   e              i   u

               1
                   a       g         s                 pug

        page   2                                 pig



                               peg        pest
PHONE BOOK SEARCH..
• Trie data structure are mostly used to search for
  a contact on phone book.

• Prefix Matching
      a = a*
Example
              a    bc…             r     s   …z       Contacts in Phone book
          0                                                    alberto
                                                  t            ram
                              a                                sankar
alberto       ram         1                                    star
                                                               stella
                              a          e

                  sanka   2
                  r
                                  star                stella
PHONE BOOK SEARCH..

• Suffix Matching


• Can be used to index all       E


suffixes in a text in order to
carry out fast full text
searches.
TRIES IN T9
• T9 is a technology used on many mobile phones to
 make typing text messages easier.
• The idea is simple - each number of the phone's keypad
 corresponds to 3-4 letters of the alphabet.
• Many phones will notice when you type in a word that is
 not in its dictionary, and will add that word. Others keep
 track of the frequency of certain words and favor those
 words over other words that have the same sequence of
 keypresses.
TRIES IN T9

• How does a T9 dictionary work?
• It can be implemented in several ways, one of
 them is Trie. The route is represented by the
 digits and the nodes point to collection of words.
• T9 works by filtering the possibilities down
 sequentially starting with the first possible
 letters.
TRIES IN T9

• It can be implemented using nested hash tables
 as well, the key of the hash table is a letter and
 on every digit the algorithm calculates all
 possible routes (O(3^n) routes).
• For example, If we type '4663' we get 'good'
 when we press down button we get 'gone' then
 'home' etc..
Application of tries

Contenu connexe

Tendances

Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sortDistrict Administration
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Linear Search
Linear SearchLinear Search
Linear SearchSWATHIR72
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxAlbin562191
 
UNIT III NON LINEAR DATA STRUCTURES – TREES
UNIT III 	NON LINEAR DATA STRUCTURES – TREESUNIT III 	NON LINEAR DATA STRUCTURES – TREES
UNIT III NON LINEAR DATA STRUCTURES – TREESKathirvel Ayyaswamy
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Aman Sharma
 
Insertion Sort Algorithm
Insertion Sort AlgorithmInsertion Sort Algorithm
Insertion Sort AlgorithmGail Carmichael
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of joinraj upadhyay
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sortingKrish_ver2
 

Tendances (20)

Indexing Data Structure
Indexing Data StructureIndexing Data Structure
Indexing Data Structure
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sort
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Hash tables
Hash tablesHash tables
Hash tables
 
Quick sort
Quick sortQuick sort
Quick sort
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
Linear Search
Linear SearchLinear Search
Linear Search
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
AVL tree animation.ppt
AVL tree animation.pptAVL tree animation.ppt
AVL tree animation.ppt
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
UNIT III NON LINEAR DATA STRUCTURES – TREES
UNIT III 	NON LINEAR DATA STRUCTURES – TREESUNIT III 	NON LINEAR DATA STRUCTURES – TREES
UNIT III NON LINEAR DATA STRUCTURES – TREES
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Insertion Sort Algorithm
Insertion Sort AlgorithmInsertion Sort Algorithm
Insertion Sort Algorithm
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
 
3.9 external sorting
3.9 external sorting3.9 external sorting
3.9 external sorting
 

En vedette

Tries - Tree Based Structures for Strings
Tries - Tree Based Structures for StringsTries - Tree Based Structures for Strings
Tries - Tree Based Structures for StringsAmrinder Arora
 
Data structure tries
Data structure triesData structure tries
Data structure triesMd. Naim khan
 
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 tanmayTanmay 'Unsinkable'
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data StructureAnuj Modi
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Advance data structure
Advance data structureAdvance data structure
Advance data structureashok kumar
 
Introduction of suffix tree
Introduction of suffix treeIntroduction of suffix tree
Introduction of suffix treeLiou Shu Hung
 
Packet forwarding in wan.46
Packet  forwarding in wan.46Packet  forwarding in wan.46
Packet forwarding in wan.46myrajendra
 
Avl trees
Avl treesAvl trees
Avl treesppreeta
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix ArrayHarshit Agarwal
 
Binary Search Trees - AVL and Red Black
Binary Search Trees - AVL and Red BlackBinary Search Trees - AVL and Red Black
Binary Search Trees - AVL and Red BlackAmrinder Arora
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__treesmeghu123
 

En vedette (20)

Tries - Tree Based Structures for Strings
Tries - Tree Based Structures for StringsTries - Tree Based Structures for Strings
Tries - Tree Based Structures for Strings
 
Data structure tries
Data structure triesData structure tries
Data structure tries
 
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
 
Trie tree
Trie treeTrie tree
Trie tree
 
Trie (1)
Trie (1)Trie (1)
Trie (1)
 
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
 
Lec18
Lec18Lec18
Lec18
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Advance data structure
Advance data structureAdvance data structure
Advance data structure
 
Introduction of suffix tree
Introduction of suffix treeIntroduction of suffix tree
Introduction of suffix tree
 
Packet forwarding in wan.46
Packet  forwarding in wan.46Packet  forwarding in wan.46
Packet forwarding in wan.46
 
Avl trees
Avl treesAvl trees
Avl trees
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix Array
 
B tree short
B tree shortB tree short
B tree short
 
Introduction to statistics ii
Introduction to statistics iiIntroduction to statistics ii
Introduction to statistics ii
 
Distributed Hash Table
Distributed Hash TableDistributed Hash Table
Distributed Hash Table
 
Binary Search Trees - AVL and Red Black
Binary Search Trees - AVL and Red BlackBinary Search Trees - AVL and Red Black
Binary Search Trees - AVL and Red Black
 
Avl trees
Avl treesAvl trees
Avl trees
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
 

Similaire à Application of tries

CPP18 - String Parsing
CPP18 - String ParsingCPP18 - String Parsing
CPP18 - String ParsingMichael Heron
 
Computer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in pythonComputer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in pythonalin173596
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxkalai75
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxhardii0991
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxSreeLaya9
 
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 IndexHPCC Systems
 
B tree ,B plus and graph
B tree ,B plus and graph B tree ,B plus and graph
B tree ,B plus and graph RaaviKapoor
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxlemonchoos
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxYusra11491
 
introduction to python
 introduction to python introduction to python
introduction to pythonJincy Nelson
 
1. python programming
1. python programming1. python programming
1. python programmingsreeLekha51
 
CSharp for Unity - Day 1
CSharp for Unity - Day 1CSharp for Unity - Day 1
CSharp for Unity - Day 1Duong Thanh
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNratnapatil14
 

Similaire à Application of tries (20)

DS.pptx
DS.pptxDS.pptx
DS.pptx
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Delphi L02 Controls P1
Delphi L02 Controls P1Delphi L02 Controls P1
Delphi L02 Controls P1
 
CPP18 - String Parsing
CPP18 - String ParsingCPP18 - String Parsing
CPP18 - String Parsing
 
Computer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in pythonComputer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in python
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
 
Editors l21 l24
Editors l21 l24Editors l21 l24
Editors l21 l24
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
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
 
B tree ,B plus and graph
B tree ,B plus and graph B tree ,B plus and graph
B tree ,B plus and graph
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptx
 
introduction to python
 introduction to python introduction to python
introduction to python
 
1. python programming
1. python programming1. python programming
1. python programming
 
FinalReport
FinalReportFinalReport
FinalReport
 
CSharp for Unity - Day 1
CSharp for Unity - Day 1CSharp for Unity - Day 1
CSharp for Unity - Day 1
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
 

Plus de Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base classTech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimationTech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
String & its application
String & its applicationString & its application
String & its applicationTech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applicationsTech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pcTech_MX
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbmsTech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbmsTech_MX
 

Plus de Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Uid
UidUid
Uid
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Spss
SpssSpss
Spss
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Set data structure
Set data structure Set data structure
Set data structure
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
More on Lex
More on LexMore on Lex
More on Lex
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 
Linkers
LinkersLinkers
Linkers
 

Dernier

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Dernier (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

Application of tries

  • 2. Why Trie Data Structure? • Searching trees in general favor keys which are of fixed size since this leads to efficient storage management. • However in case of applications which are retrieval based and which call for keys varying length, tries provide better options. • Tries are also called as Lexicographic Search trees.
  • 3. Definition For Trie: • A trie of order m may be empty. • If not empty, then it consists of an ordered sequence of exactly m tries of order m. • The branching at any level of the trie is determined only by the portion and not by the whole word. • Alphabetic keys require a trie of order 27(26 letters of the alphabet + a blank) for their storage and
  • 4. Representation Of Trie • The trie have two category of node structures. ▫ Branch node ▫ Information node • A branch node is merely a collection of LINK fields each pointing either to a branch node or to an information node. • An information node holds the keys that is to be stored in the trie.
  • 5. Operations In Trie • The three operations in the trie data Structure are • Searching a trie • Insertion • Deletion
  • 6. Example • Construct a Trie for the keys 001,100,111,011,010 STEP 1: Insert (001,100) 0 1 001 100
  • 7. Example • STEP 2: 0 1 Insert(111) 0 1 001 100 111
  • 8. Example • STEP 3: Insert(011) 0 1 0 1 0 1 001 011 100 111
  • 9. Example • STEP 4: Insert(010) 0 1 0 1 0 1 001 100 111 010 011
  • 10. INSERTION • To Insert a key K into the trie we begin as we would to search for the key k, possibly moving down the trie. • At the point where the LINK field of the branch node leads to NIL, the key k is inserted as an information node.
  • 11. Insertion • In the Above constructed trie INSERT A KEY 101. 0 1 0 1 0 1 001 111 010 011 100 101
  • 12. Deletion • The deletion of a key K from a trie proceeds as one would to search for the key. • On reaching the information node(node l)holding k, the same is deleted. ▫ It need to be ensured the branch node to which node l is linked accommodates other information node as well!  If there is more than1 information node/if there is at least one LINK field/or both ,then deletion id done.  If it leaves the branch node with just one more key ,we delete the branch node and push the node to a higher level  If the situation leads to node being the only non empty node , once again we delete the branch node and push node to a higher level.
  • 13. Deletion • Delete 010: 0 1 0 1 0 1 001 111 010 011 100 101
  • 14. Performance Of trie • The performance of search trees is determined by the number of keys that form the tree. • The complexities of the search ,delete and insert operations were given by O(h) where the height h is dependent on the number of keys represented in the search tree. • In contrast, the performance of the trie is dependent on the length of the key-The number of characters forming the key rather than the number of keys itself.
  • 15. APPLICATIONS OF TRIE DATA STRUCTURES
  • 16. TRIES IN AUTO COMPLETE • Since a trie is a tree-like data structure in which each node contains an array of pointers, one pointer for each character in the alphabet. • Starting at the root node, we can trace a word by following pointers corresponding to the letters in the target word. • Starting from the root node, you can check if a word exists in the trie easily by following pointers corresponding to the letters in the target word.
  • 17. AUTO COMPLETE • Auto-complete functionality is used widely over the internet and mobile apps. A lot of websites and apps try to complete your input as soon as you start typing. • All the descendants of a node have a common prefix of the string associated with that node.
  • 18.
  • 19. AUTO COMPLETE IN GOOGLE SEARCH
  • 20. WHY TRIES IN AUTO COMPLETE • Implementing auto complete using a trie is easy. • We simply trace pointers to get to a node that represents the string the user entered. By exploring the trie from that node down, we can enumerate all strings that complete user’s input.
  • 21. CRIMINOLOGY • Suppose that you are at the scene of a crime and observe the first few characters CRX on the registration plate of the getaway car. If we have a trie of registration numbers, we can use the characters CRX to reach a subtrie that contains all registration numbers that begin with CRX. The elements in this subtrie can then be examined to see which cars satisfy other properties that might have been observed.
  • 22. AUTOMATIC COMMAND COMPLETION • When using an operating system such as Unix or DOS, we type in system commands to accomplish certain tasks. For example, the Unix and DOS command cd may be used to change the current directory.
  • 23. Commands that have the prefix “ps” • ps2ascii ps2pdf psbook psmandup psselect • ps2epsi ps2pk pscal psmerge pstopnm • ps2frag ps2ps psidtopgm psnup pstops • ps2gif psbb pslatex psresize pstruct • Figure 10 Commands that begin with "ps" We can simply the task of typing in commands by providing a command completion facility which automatically types in the command suffix once the user has typed in a long enough prefix to uniquely identify the command. For instance, once the letters psi have been entered, we know that the command must be psidtopgm because there is only one command that has the prefix psi. In this case, we replace the need to type in a 9 character command name by the need to type in just the first 3 characters of the command!
  • 24. LONGEST PREFIX MATCHING • Longest prefix match (also called Maximum prefix length match) refers to an algorithm used by routers in Internet Protocol (IP) networking to select an entry from a routing table . • Because each entry in a routing table may specify a network, one destination address may match more than one routing table entry. The most specific table entry — the one with the highest subnet mask — is called the longest prefix match. It is called this because it is also the entry where the largest number of leading address bits in the table entry match those of the destination address.
  • 25. For example, consider this IPv4 routing table (CIDR notation is used): 192.168.20.16/28 192.168.0.0/16 When the address 192.168.20.19 needs to be looked up, both entries in the routing table "match". That is, both entries contain the looked up address. In this case, the longest prefix of the candidate routes is 192.168.20.16/28, since its subnet mask (/28) is higher than the other entry's mask (/16), making the route more specific.
  • 26. • A network browser keeps a history of the URLs of sites that you have visited. By organizing this history as a trie, the user need only type the prefix of a previously used URL and the browser can complete the URL.
  • 27.
  • 28. SPELL CHECKERS • Spell checkers are ubiquitous. Word processors have spell checkers, as do browser-based e-mail clients. They all work the same way: a dictionary is stored in some data structure, then each word of input is submitted to a search in the data structure, and those that fail are flagged as spelling errors
  • 29. SPELL CHECKERS • There are many appropriate data structures to store the word list, including a sorted array accessed via binary search, a hash table, or a bloom filter. In this exercise you are challenged to store the word list character-by-character in a trie.
  • 31. Spell Check.. a bc… 0 p …z 0 a e i u 1 a g s pug page 2 pig peg pest
  • 32. PHONE BOOK SEARCH.. • Trie data structure are mostly used to search for a contact on phone book. • Prefix Matching a = a*
  • 33. Example a bc… r s …z Contacts in Phone book 0 alberto t ram a sankar alberto ram 1 star stella a e sanka 2 r star stella
  • 34. PHONE BOOK SEARCH.. • Suffix Matching • Can be used to index all E suffixes in a text in order to carry out fast full text searches.
  • 35. TRIES IN T9 • T9 is a technology used on many mobile phones to make typing text messages easier. • The idea is simple - each number of the phone's keypad corresponds to 3-4 letters of the alphabet. • Many phones will notice when you type in a word that is not in its dictionary, and will add that word. Others keep track of the frequency of certain words and favor those words over other words that have the same sequence of keypresses.
  • 36. TRIES IN T9 • How does a T9 dictionary work? • It can be implemented in several ways, one of them is Trie. The route is represented by the digits and the nodes point to collection of words. • T9 works by filtering the possibilities down sequentially starting with the first possible letters.
  • 37. TRIES IN T9 • It can be implemented using nested hash tables as well, the key of the hash table is a letter and on every digit the algorithm calculates all possible routes (O(3^n) routes). • For example, If we type '4663' we get 'good' when we press down button we get 'gone' then 'home' etc..