Inserting method based on tree-shaped data structure node and storing device

A data structure and storage device technology, applied in the storage field, can solve the problems of slow node insertion speed and increased node insertion time, and achieve the effect of reducing the insertion time and increasing the insertion speed

Active Publication Date: 2009-08-26
HUAWEI TECH CO LTD
View PDF0 Cites 24 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0005] The inventor found in the process of realizing the present invention that: in a tree with a fixed shape, inserting a new node needs to move the existing nodes, and the number of nodes to be moved will increase exponentially with the height of the tree, resulting in node The insertion time increases rapidly; the node insertion speed in the existing tree data structure is slow

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Inserting method based on tree-shaped data structure node and storing device
  • Inserting method based on tree-shaped data structure node and storing device
  • Inserting method based on tree-shaped data structure node and storing device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0052] Embodiment one, such as image 3 As shown, the embodiment of the present invention provides a method for inserting nodes based on a tree data structure, including the following steps:

[0053] Step 301: Find the nearest main tree node in the main tree according to the key code value of the node to be inserted, the key code value of the above-mentioned nearest main tree node is smaller than and closest to the key code value of the node to be inserted; the root node of the above-mentioned main tree is initialized has the minimum key code value; wherein, the above-mentioned main tree includes a parent node, a left child node of the above-mentioned parent node and a right child node of the above-mentioned parent node, and the above-mentioned left child node is larger than the above-mentioned parent node, and the above-mentioned parent node is larger than the above-mentioned right child node node

[0054] In a tree, the key code value of the inserted node will take a value ...

Embodiment 2

[0085] Embodiment two, such as Figure 5 As shown, the embodiment of the present invention also provides a search method based on tree data structure nodes, which may include the following steps:

[0086] Step 501: Find the node to be searched in the main tree according to the key code value of the node to be searched; if the above-mentioned node to be searched does not exist in the main tree, then search for the nearest main tree node; the key code value of the above-mentioned nearest main tree node is less than and the closest The key code value close to the node to be inserted;

[0087] If there is a node in the main tree that has the same key code value as the node to be searched, then the node to be searched has been found, and the search process can end;

[0088] Step 502: take the slave tree pointed to by the external pointer of the nearest master tree node as the current slave tree;

[0089] Step 503: Find the node to be found in the current slave tree.

[0090] In ...

Embodiment 3

[0101] Embodiment three, such as Figure 7 As shown, the embodiment of the present invention also provides a method for deleting nodes based on a tree data structure, which may include the following steps:

[0102] Step 701: Search for the node to be deleted in the main tree according to the key code value of the node to be deleted. If the above-mentioned node to be deleted does not exist in the main tree, search for the nearest main tree node; the key code value of the above-mentioned nearest main tree node is less than and the closest Close to the key code value of the node to be deleted;

[0103] If there is a node in the main tree with the same key code value as the node to be deleted, the node to be deleted has been found at this moment, and step 704 can be directly entered;

[0104] Step 702: take the slave tree pointed to by the external pointer of the nearest master tree node as the current slave tree;

[0105] Step 703: Find the above-mentioned node to be deleted in...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The embodiment of the present invention discloses an inserting method based on tree-shaped data structure node and a storing device. The method includes steps of searching nearest main tree node according to key code value of node to be inserted, wherein the key code value of the nearest main tree node is smaller than and nearest to the key code value of the node to be inserted; using a secondarytree pointed by an external pointer of the nearest main tree node as present secondary tree, judging whether the present secondary tree is full, if yes, arbitrarily selecting a node in the present secondary tree as a split node, inserting the split node into the main tree as a newly-built main tree node, distributing newly-built secondary tree for the newly-built main tree, making an external pointer of the newly-built main tree node point to the newly-built secondary tree, moving all nodes arranged at left side of the split node in the present secondary tree in the newly-built secondary tree, then searching nearest main tree node, if not, inserting the node to be inserted into the present secondary tree. The invention divides the tree of the tree-shaped data structure into main tree and secondary tree, thereby reducing height of the tree and node inserting time.

Description

technical field [0001] The invention relates to the technical field of storage, in particular to a method and a storage device based on tree data structure node insertion. Background technique [0002] The tree in the tree data structure is composed of a number of natural nodes (Node) based on a certain relationship. Each node in any non-empty tree has a key value for uniquely identifying the node. In the binary tree, the above-mentioned key code value is generally represented by a key (Key). [0003] A binary tree is a tree-shaped data structure in which each node of the tree can only have at most two child nodes; any node in the binary tree is taken as the parent node. In order to distinguish the two child nodes of the current node, the two child nodes can be called respectively. The left child node and right child node of the parent node, the relationship between all nodes and their child nodes in the binary tree can be: the left child node is greater than the parent no...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F17/30
CPCG06N5/02G06F17/30961G06F16/9027
Inventor 杜文华洪荣峰易毅
Owner HUAWEI TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products