Trie (Prefix Tree)

Source: Internet
Author: User

Trie or Prefix Tree is an ordered tree data structure, which is usually stored in a Union array with strings as keywords. Different from the binary search tree, there is no node in the tree to store keywords associated with the node. It uses its position in the tree to display its related keywords. All the child nodes of any node have a string prefix associated with the node, and the root is associated with the Null String. Values are usually not associated with each node. Only leaf nodes and some internal nodes are related to the keywords of interest.

The term trie comes from "retrieval." And is pronounced as [TRI] ("Tree"). However, it is usually pronounced as [tra] "try ".

In the following example, keywords are listed in the node, and values are listed below them. Each completed English word has an integer associated with it. Trie can be viewed as a finite state automation. Although the symbols of each boundary usually imply the order of branches.

Keywords do not need to be displayed in the node (in fact, words are only displayed to illustrate how trie is implemented .)

Although it is the most common, tries does not have to use string keywords. The sameAlgorithmIt is easy to implement a similar ordered list, such as replacement of the number list and replacement of the Shape list...

 

 

 

Http://en.wikipedia.org/wiki/Trie

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.