CN101853310A - Method for producing preorder and postorder code of single traversing tree - Google Patents

Method for producing preorder and postorder code of single traversing tree Download PDF

Info

Publication number
CN101853310A
CN101853310A CN201010204349A CN201010204349A CN101853310A CN 101853310 A CN101853310 A CN 101853310A CN 201010204349 A CN201010204349 A CN 201010204349A CN 201010204349 A CN201010204349 A CN 201010204349A CN 101853310 A CN101853310 A CN 101853310A
Authority
CN
China
Prior art keywords
postorder
code
preorder
xml
coding
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201010204349A
Other languages
Chinese (zh)
Inventor
徐潇然
邓志鸿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Peking University
Original Assignee
Peking University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Peking University filed Critical Peking University
Priority to CN201010204349A priority Critical patent/CN101853310A/en
Publication of CN101853310A publication Critical patent/CN101853310A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a method for simultaneously constructing a preorder code and a postorder code of an XML (Extensive Makeup Language) document through single traversing, belonging to the field of data structures and algorithms. The invention combines same traversing orders in the preorder code and the postorder code by separating the traversing order and the coding order of an XML node, has the key technical point of correctly locating the opportunity of going in and out the node, and simultaneously maintains two independently increasing preorder coding order and postorder coding order. When single scan to an XML tree is finished, each node can obtain a unique preorder code and a unique postorder code per se. In the invention, the consumption of two-time scan is lowered to single scan, the time of the method for producing the preorder code and the postorder code by single scan is halved when the data quantity is large, and the process of the XML document constructing an index is greatly accelerated.

Description

The method of producing preorder and postorder code of single traversing tree
Technical field
The invention provides a kind of method of the XML of foundation index, be specifically related to a kind of single ergodic XML document and generate front and back preface Methods for Coding, belong to data structure and algorithm field.
Background technology
Existing XML index technology with the XML data cell as recorded and stored, preserve the positional information that helps determine structural relation between node simultaneously, positional information is divided into two classes usually, one class is the sequence number of node in certain traversal method gained character string, and another kind of is the routing information of node in XML document.Index coded system based on the front and back preface can intactly reflect the internodal structural relation of XML, and then XML document is expressed as a sequence of being made up of node.
Front and back preface coding is a kind of interval coded system, its basic thought is with the interval (pre of the sequence in formerly preface ergodic sequence and the postorder traversal sequence to forming, post) as the positional information of node, its base index record form is (s, pre, post), wherein s is the tag attributes of node in the XML tree.The mode of front and back preface coding often is applied to make up the index of XML document.
Usually the front and back preface coding that obtains XML all needs to carry out preorder traversal and twice scanning of postorder traversal, and the time cost that twice scanning is consumed when XML document is very big is huge.
Summary of the invention
The object of the present invention is to provide a kind of method, realize preorder and postorder coding simultaneously by single sweep operation XML tree, so as to solving the time loss problem that twice common scanning brings.
Principle of the present invention is that the traversal preface of XML node and code sequence are separated, and merges identical traversal preface in preamble and the postorder coding then, and then realizes the scheme of single sweep operation.The XML sequence node shape that obtains in the preface in traversal is as " go into A, go into B, go into C, go out C; go into D, go out D, go out B, go into E; go out E, go out A ", and preamble is the opportunity of triggering coding, i.e. A with the ingress, B, C, D, E, and postorder coding is the opportunity of triggering coding with the egress, i.e. C, D, B, E, A specifically sees Fig. 2.Can travel through (or postorder coding traversal) scheme with reference to preamble to XML traversal of tree process, crucial technology point for correctly locate, opportunity of egress, and safeguard two independent preamble preface and postorder code sequences that increase simultaneously, each node all will obtain unique preamble and the postorder coding of oneself when finishing the single pass that XML is set.In program code, set up enter recursive function forward and backward to be respectively opportunity, and state that two global variables are used for preserving the preamble preface and the postorder code sequence of current growth into, egress.
Technical scheme of the present invention is as follows:
Defined function V, its parameter for the tree node n, the execution flow process of this function as shown in Figure 1, its implementation is as follows:
1) if. parameter n is null, then withdraws from this function; Otherwise carry out 2);
2). make up preamble;
3). parameter n is defined as its left child node, recursive call function V;
4). make up the postorder coding;
5). make up preamble;
6). parameter n is defined as its right child node, recursive call function V;
7). make up the postorder coding;
8). function finishes.
The present invention realizes preorder and postorder Methods for Coding simultaneously by the single sweep operation XML document, the consumption of twice scanning is reduced to once, when data volume was very big, the preface Methods for Coding had reduced the time overhead of half before and after single sweep operation generated, and had quickened the process of XML document index building greatly.
Description of drawings
Fig. 1 is for carrying out the process flow diagram that the single traverse tree generates front and back preface coding;
The example of Fig. 2 for a tree is traveled through.
Embodiment
The present invention is further elaborated with a specific embodiment below.
Fig. 2 is the example of preface coding before and after a single sweep operation generates, and this tree has 5 nodes, and wherein A is a root node.Carry out ergodic process through method provided by the invention, can draw following result:
This traversal of tree sequence is: go into A, go into B, go into C, go out C, go into D, go out D, go out B, go into E, go out E, go out A; The sequence of preamble is: A, B, C, D, E; The sequence of postorder coding is: C, D, B, E, A.Therefore realized the single ergodic tree function of coding front and back preface simultaneously.
It should be noted that at last the purpose of publicizing and implementing example is to help further to understand the present invention, but it will be appreciated by those skilled in the art that: without departing from the spirit and scope of the invention and the appended claims, various substitutions and modifications all are possible.Therefore, the present invention should not be limited to the disclosed content of embodiment, and the scope of protection of present invention is as the criterion with the scope that claims define.

Claims (2)

1. one kind makes up XML preorder and postorder Methods for Coding, it is characterized in that, described method to the traversal number of times of XML document for once; Its implementation is: defined function V, and its parameter is the node n of tree, the implementation method of this function is as follows:
1) if. parameter n is null, then withdraws from this function; Otherwise carry out 2);
2). make up preamble;
3). parameter n is defined as its left child node, recursive call function V;
4). make up the postorder coding;
5). make up preamble;
6). parameter n is defined as its right child node, recursive call function V;
7). make up the postorder coding;
8). function finishes.
2. the method for claim 1 is characterized in that, described preamble and postorder coding respectively are kept in the global variable; Described structure preamble and structure postorder coding are meant the maintenance to this global variable.
CN201010204349A 2010-06-21 2010-06-21 Method for producing preorder and postorder code of single traversing tree Pending CN101853310A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010204349A CN101853310A (en) 2010-06-21 2010-06-21 Method for producing preorder and postorder code of single traversing tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010204349A CN101853310A (en) 2010-06-21 2010-06-21 Method for producing preorder and postorder code of single traversing tree

Publications (1)

Publication Number Publication Date
CN101853310A true CN101853310A (en) 2010-10-06

Family

ID=42804801

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010204349A Pending CN101853310A (en) 2010-06-21 2010-06-21 Method for producing preorder and postorder code of single traversing tree

Country Status (1)

Country Link
CN (1) CN101853310A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102446218A (en) * 2011-11-25 2012-05-09 浙江大学城市学院 Encoding method supporting dynamic updating of XML (extensive makeup language) data
CN109064126A (en) * 2018-07-18 2018-12-21 长江勘测规划设计研究有限责任公司 Hydroelectric project metrical information management method based on quality driving
CN112860882A (en) * 2021-01-18 2021-05-28 浙江大学 Book concept front-rear order relation extraction method based on neural network

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102446218A (en) * 2011-11-25 2012-05-09 浙江大学城市学院 Encoding method supporting dynamic updating of XML (extensive makeup language) data
CN109064126A (en) * 2018-07-18 2018-12-21 长江勘测规划设计研究有限责任公司 Hydroelectric project metrical information management method based on quality driving
CN109064126B (en) * 2018-07-18 2021-03-26 长江勘测规划设计研究有限责任公司 Hydropower engineering metering information management method based on quality driving
CN112860882A (en) * 2021-01-18 2021-05-28 浙江大学 Book concept front-rear order relation extraction method based on neural network
CN112860882B (en) * 2021-01-18 2022-05-10 浙江大学 Book concept front-rear order relation extraction method based on neural network

Similar Documents

Publication Publication Date Title
CN106407408B (en) A kind of the spatial index construction method and device of mass cloud data
Song et al. PRESS: A novel framework of trajectory compression in road networks
CN107590250A (en) A kind of space-time orbit generation method and device
CN107565973B (en) Method for realizing node-extensible Huffman coding and circuit structure
CN106155658A (en) The behavior tree editing machine realized based on U3D Plugin Mechanism
CN106503872B (en) A kind of business process system construction method based on basic business active set
CN105141583B (en) A kind of character string matching method and system
CN104392010A (en) Subgraph matching query method
CN104778258A (en) Data extraction method oriented to protocol dataflow
CN103092992B (en) Vector data elder generation based on Key/Value type NoSQL data base sequence quadtree coding and indexing means
US10700934B2 (en) Communication control device, communication control method, and computer program product
CN106713273A (en) Protocol keyword identification method based on lexicographic tree pruning search
CN101853310A (en) Method for producing preorder and postorder code of single traversing tree
US20160006814A1 (en) Method for propagating network management data for energy-efficient iot network management and energy-efficient iot node apparatus
CN101656622A (en) Alarm management system and alarm management method
CN104820700B (en) The processing method of substation's unstructured data
CN106294805A (en) Data processing method and device
CN107124396B (en) Method for structuring processing of IEC61850 GOOSE message machine data
CN110333990B (en) Data processing method and device
CN103473271B (en) A kind of optimization storage method for mass data
CN114124918A (en) Message parsing method and device
CN103400050A (en) Multiple-user cooperative nuclear reactor risk determining method and system
CN101917282A (en) Method, device and system for processing alarm shielding rules
CN104036141A (en) Open computing language (OpenCL)-based red-black tree acceleration algorithm
CN104199649B (en) The path method for decomposing of interactive information between a kind of process for father and son

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Open date: 20101006