Trie - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Trie

Description:

The letter field of the root is irrelevant. ... equal to the number of different characters in the alphabet from which the words ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 9
Provided by: IRE62
Category:
Tags: alphabet | letters | of | trie

less

Transcript and Presenter's Notes

Title: Trie


1
Trie
  • Irena Pevac
  • CS501

2
Dictionary ADT
  • Dictionary ADT is set of elements with the
    following basic operations
  • insertion
  • deletion
  • lookup

3
Implementing Dictionary ADT
  • Dictionary can be implemented with
  • array
  • sorted array
  • linked list
  • trie
  • leftmost child - right - sibling
  • binary search trees
  • hash tables

4
Trie
  • Trie is used to model dictionary ADT.
  • We use tree where each node except the root has
    one character and a boolean value true or false.
  • String of characters represented by a node n with
    boolean value true is the sequence of characters
    along the path from the root to n.

5
Example
  • Construct a trie for the dictionary consisting of
    the following few words
  • boot, root, bee, be, bond, boss, rose

6
Trie
7
Implementation of Trie
  • For dictionary that contains words in English
    language we use a tree with nodes having one
    letter, one boolean and 26 references to at most
    26 children. The letter field of the root is
    irrelevant. Here we assume that only uppercase or
    only lowercase letters are used.
  • Nodes in a trie in general have a branching
    factor equal to the number of different
    characters in the alphabet from which the words
    are formed.

8
Cost of Basic Operations
  • Insert O(1)
  • Delete O(1)
  • Lookup O(1)
Write a Comment
User Comments (0)
About PowerShow.com