Solid Trees in Data Structure

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

For the given forest, we create some of the given edges “dashed” and the rest of them are kept solid. Each non-leaf node is associated with only one “solid” edge to one of its children. All other children will be connected with the help of a dashed edge.

To be more concrete, in any given tree, the right-most link (to its child) should be kept solid, and all other links to its other children are created “dashed”.

As a result, the tree will be broken into a collection of solid paths. The roots of solid paths will be joined to some other solid path by a dashed edge. A new data structure denoted a “virtual tree” is constructed. Each linking and cutting tree T is represented by a virtual tree V , containing the same set of nodes. But each solid path of the original tree is modified or converted into a binary tree in the virtual tree; binary trees are as balanced as possible. Thus, a virtual tree is associated with a (solid) left child, a (solid) right child and zero or more (dashed) middle children.

In other words, a virtual tree consists of a hierarchy of solid binary trees joined by dashed edges. Each node is associated with a pointer to its parent, and to its left and right children.

We know that each path is converted into a binary tree. Parent (say q) of a node (say p) in the path is the in-order (symmetric order) successor of that node (p) in the solid tree. However, if p is the last node (in symmetric order) in the solid sub-tree then its parent path will be the parent of the root of the solid sub-tree containing it.

Formally, Parentpath(v) =Node(Inorder(v)+ 1).

Note that for any node v, all nodes in the left sub-tree will have less inorder numbers and those in the right sub-tree will have higher inorder numbers. This ensures that all nodes in the left subtree are denoted as descendants and all nodes in the right sub-tree are denoted as ancestors. Thus, the parent (in the binary tree) of a left child will be treated as an ancestor (in the original tree). But, parent (in the binary tree) of a right child is treated as a descendant (in the original tree). This order, helps us to carry out add cost effectively.

We need some definitions or notation to proceed.

Let mincost(x) be the cost of the node having the minimum key value among all descendants of x in the same solid sub-tree.

Then in each node we store two fields δcost(x) and δmin(x). We define,

δmin(x) =cost(x)−mincost(x). And,
δcost(x) =cost(x)− cost(parent(x)) if x is associated with a solid parent
δcost(x) =cost(x) otherwise (x is treated as a solid tree root)
raja
Published on 07-Jan-2020 16:42:53
Advertisements