Left Right Binary Tree

This is useful for the implementation of storing a huge number of data (lets say it > 1000) which have the behavior of parent and child (like a binary tree). I remembered that in the Data Structure, our professor used to give a lecture about this left right binary tree. But, who care about the efficiency of data storage, when they're mere a student?

So, simply speaking, it goes like this. Imagine that the data is formed like a binary tree. Each node represent an item. Each node has left id and right id. Root has left id = 1. Root's left child has left id = 2. And so on. (consult the left right binary tree manual book for the id rule). The point is that the left right if will be useful for selecting childs or parents. When we'd like to select the child of a node, select node of which left id is > the node's left id and right id is < the node's right id. A node's parent is a node which has left id = itself's left id minus 1.

This will make the data query become efficient.

0 comments: (+add yours?)