Tuesday, 6 June 2017

Explain labelling algorithm for code generation?


 Algorithm for labeling the nodes of tree(DAG):

1. For Leaf Nodes
           Assign label 1 to left child node and label 0 to right child node.

2. For Interior Nodes
          Case 1: If Node's children's labels are different, then 
          Node's Label = Maximum among Children's Labels.
          Case 2: If Node's children's labels are same, then
          Node's Label = (Left Child's Label OR Right Child's Label) + 1.

No comments:

Post a comment