Proof of leaf node check[t]=t in trie tree of even-numbered groups

Source: Internet
Author: User

The even-numbered group Trie tree, in fact, uses two one-dimensional arrays to represent the data structure of the trie tree.

An array is called base and the other array is a check. The transfer conditions are as follows:

For status S, receive character C, transfer to state T

Base[s]+c=t
Check[t]=base[s]

    1. Base array to store nodes
    2. Check array identifies the precursor information of the node

For root nodes, define:

The root node has a status of 0,\ (t_ root =0\) .

The base address of the root node is 1, which is stored in the base array subscript 0, so \ (base[t_ root]=base[0]=1\).

\ (check[t_ root]=check[0]=0\)

For a node NodeA in the Trie tree, the following information is available:

    • Character ' A ', this is for people to see
    • The state of the character ' a ', denoted by \ (t_a\) ,\ (t_a\) is an integer. From the root node, the conditional ' A ' is transferred to NodeA, which is:\ (Base[0]+code (a) =t_a=1+65=66\), where code (a) is typically the ASCII code for that character.
    • The base address of the character ' a ', using the base array to save
    • Because the NodeA of the node corresponding to the character ' A ' is the root node, i.e. \ (check[t_a]=base[0]=1\)

For the leaf node node_leaf, the base address defining the leaf node is begin, the state is T_leaf, code (NODE_LEAF) = 0,

Now to prove: check[t_leaf]=t_leaf

    1. Begin+code (node_leaf) =t_leaf get: Begin=t_leaf
    2. Base[begin+code (node_leaf)]=t_leaf get: Base[begin]=t_leaf
    3. Check[t_leaf]=base[begin] Got: check[t_leaf]=t_leaf

The 2nd and 3 points are obtained by the transfer condition, and the proof is complete.

In addition, in this article of Hancks, the following references are available:

3. Then set the check for this group of sibling nodes to Check[begin + a1...an] = begin; Obviously, the value of the leaf node I check[i] must be equal to I, because it is the first in the sibling node, and its code is 0.

It's a good idea.
In addition, for the leaf node, base[t_leaf]=-index, reference, wherein-index said: The leaf node represents the key words in the dictionary order. (When constructing an even-numbered group tree, the dictionary is loaded into TreeMap and is ordered)

Proof of leaf node check[t]=t in trie tree of even-numbered groups

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.