Originally, in the data structure textbook, there is no data structure called a "chain Tree", and Goolge cannot be found. This kind of data structure is used to search for POI keywords in GIS systems at high speed. On the basis of the n-tree, a improved data structure is called a chain tree for convenience of discussion.
A chain tree is a data structure formed by attaching each tree node (including the roots and leaves) to a chain table on the basis of the n-tree.
It indicates a typical chain tree.
Figure 1
Two notable features of the chain tree are:
1. The linked list elements attached to a tree node are the set of linked list elements attached to all child nodes of the Tree node (if any) (no duplicate nodes ).
2. The root node of the chain tree can be a virtual node, representing the ancestor of all entity nodes in the system. In this way, it is unnecessary to form a chain tree forest. The root node in Figure 1 is a virtual node, and all the other nodes are solid nodes.
Ranking tree search algorithm
This algorithm indicates that, based on the key word sequence, a node from the chain root node is routed in the chain tree, and a tree node with the maximum matching of the chain tree path and the key word sequence is finally found, then the algorithm of the linked list is used.
Take the sort tree shown in Figure 1 as an example. Assume that the keyword of each tree node is the tag character on it. If the sequence of keywords to be searched is "ACI ", the execution sequence of the algorithm is: 1. start from the root node and find the tree node with the keyword 'A.
There are two children under the Root node Root, 'A' and 'x' respectively, because all the children of the sorting Tree node are sorted according to certain rules, therefore, this step can be performed using binary search. If the Root user has n Children, this step takes lgn time. 2. find the child whose keyword is 'C' among all the children of 'A.
Similarly, if 'a has m children, this step takes time to lgm. 3. find the child whose keyword is 'I among all the children of 'C.
We also use binary lookup. If 'C' has p children, this step takes time to complete with lgp, the search time for the keyword sequence "ACI" is lgn + lgm + lgp. according to the characteristics of the chain tree, there are n> = k> = p, so the time complexity of the search for a keyword sequence with a length of 3 is O (3lgn), extended, we get a more general ranking chain tree search algorithm complexity: If the keyword sequence length is k, the total number of entity nodes in the system is n, the time complexity of the search algorithm in the ranking tree is O (klgn ).
About POI
In GIS, a Point with detailed information on a map is called POI (Point Of Interest ). For example, the POI named "Beijing Xidan Book Tower" contains a series of detailed information about the location, which usually includes:
1. The name of the POI, which is "Xidan Book Tower"
2. Longitude and latitude of the POI
3. the POI address
4. the POI type
5. Description of the POI
6. the POI phone number
7. the POI URL
8. This POI photo
9. The audio and video of the POI
......
Generally, there are millions of such POI in a city. The data volume is quite large.
Keyword Search for POI
In GIS-related applications, a basic function is to search for a series of POI related to the keyword Based on the keyword entered by the user, the POI is presented to the user based on the order in which it matches the user input strings. The keyword entered by the user may be related to the POI name or the address, type name, description information, URL, and other fields of the POI. Theoretically, as long as a field in POI or a combination of several fields is related to the keyword entered by the user, the POI should appear in the appropriate position in the search result list.
For example, if the keyword entered by the user is "Peking University", the searched POI may include:
Great Northern Wilderness (The names include 'North' and 'day', and these two words are connected together)
Peking University (the names include 'North' and 'day'. These two keywords are separated and called jumpers)
Beijing University of Posts and Telecommunications (the name includes "North", "big", and text jump)
Dabei kiln (the name contains 'North' and 'day', but these two keywords are reversed, called inverse words)
Unnamed Lake (the address contains the word "North" and "Big)
......
Of course, according to our general idea, Peking University should rank first, Because Peking University generally refers to it. Therefore, the GIS system requires Beijing University to be the first in this search.
In order to simplify the problem, this article only searches for the keyword field of the POI name. That is to say, only POI associated with the name field and the user input string is searched.