Key tree application in the billing system

Source: Internet
Author: User

First, let's take a look at what happened to the key tree:

The key tree is also known as the digital search tree or trie tree (trie is the four characters in the middle of retrieve ), its structure is inspired by a large Dictionary's "book-side logo ". The first letter in the dictionary is a, B, c ,.... Z word page, and then mark each part with the second letter A, B, C ,... Z word page ,.... and so on.

1: Key tree Definition
A key tree is a special search tree. Unlike other search trees, a node in a key tree does not contain one or more keywords, it only contains a part of a keyword (character or number). For example, if the keyword is a numerical value, the node contains only one digit. If the keyword is a word, the node contains only one letter.

2: Key tree storage

There are two methods to store the key tree:
(1) Double-link Tree Representation
If it is represented by the child brother of the tree, each node contains three fields.
A: Symbol field: a character that stores keywords.
B: son domain: stores the pointer to the root of the first subtree, and the son domain of the leaf node points to the pointer of this keyword record.
C: Brother domain: stores the pointer to the right brother.

At this time, the key tree is also called a double-link tree.
// Storage representation of the double-link tree
Typedef struct dulnode {
Char symbol; // Node Character Field
Struct dulnode * son, * brother; // son points to the Child root node, and brother points to the right brother node.
} Dulnode, * dltree;

(2) Multiple linked list Representation

If multiple linked lists of trees are used to represent the key tree, each node of the tree should contain D (D is the base of the key character, for example, when the character set is composed of uppercase letters, then d = 26 + 1 = 27) pointer field. The key tree is also called the trie tree. If each node has only one child in the path from a node in the key tree to the leaf node, You can compress all nodes in the path into one "leaf node ", store the keyword and pointer to the record in the leaf node.
 

The above data structure is easily reminiscent of a telephone number. If the keyword value is [], it is easy to process data such as a telephone number. If the length of the current landline phone is 8 bits, the time complexity of the query is constant 8.

User Data in the billing system is frequently used in the billing process.AlgorithmThe query speed will be greatly improved.

Next, let's talk about the realization of the key-tree algorithm and the implementation in the shared memory.

 

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.