pc-trees & pq-trees. 2 table of contents review of pq-trees –template operations introducing...
DESCRIPTION
3 Order of Leaves in a Tree Usually we do not specify the child order in a (rooted) tree –When you lay down a tree on the plane there are many ways to do this so that the leaf orders are different How many different ways can you order the leaves of a tree? In some data structure it is important to specify certain child orders for certain nodesTRANSCRIPT
![Page 1: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/1.jpg)
PC-Trees & PQ-Trees
![Page 2: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/2.jpg)
2
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 3: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/3.jpg)
3
Order of Leaves in a Tree
• Usually we do not specify the child order in a (rooted) tree– When you lay down a tree on the plane there are
many ways to do this so that the leaf orders are different
• How many different ways can you order the leaves of a tree?
• In some data structure it is important to specify certain child orders for certain nodes
![Page 4: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/4.jpg)
4
The consecutive ones property (COP)
• COP : Can one permute the columns of a (0,1)-matrix such that the 1’s in each row are consecutive?
• One application is in the representation of the matrix, e.g. when you send the matrix through the Internet– Need only to give the “start” and “end” positions of
the 1’s for each row, and the column order– O(m+n) space instead of O(mn) for a (m x n) –
matrix.
![Page 5: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/5.jpg)
5
PQ-Trees
• There are many column permutations satisfying the COP
• One can use a PQ-tree to record all feasible permutations of the column indices– Children order of a P-node can be arbitrary– Children order of a Q-node can only be
inverted
![Page 6: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/6.jpg)
6
Q P
1 2 3 5 6
Q
4
1 2 3 4 5 61 2 3 4 5 6
1 1 0 0 0 01 1 0 0 0 0
0 1 1 0 0 00 1 1 0 0 0
1 1 1 1 0 01 1 1 1 0 0
0 0 0 1 1 10 0 0 1 1 1
PQ-trees and the COP
![Page 7: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/7.jpg)
7
Linear time algorithm on PQ-trees
• [1974] Booth and Lueker presented a linear time algorithm for the COP test based on PQ-trees
• PQ-tree can also be used to yield a linear time algorithm for interval graph recognition and planar graph recognition.
![Page 8: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/8.jpg)
8
Operations on PQ-trees
• Initially, there is a root P-node with all columns as leaves. Rows are considered one by one.
• Every time a new row comes in, we need to modify the current PQ-trees so that the columns with 1’s in this row are consecutive.
• At the end of the iteration, obtain a PQ-tree representing all feasible permutations for rows considered so far.
![Page 9: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/9.jpg)
9
Booth and Lueker’s PQ-Tree algorithm
• At each iteration consider a new row coming in.• It is a bottom-up approach consisting of two
stages:– 1. Node labeling
• The leaves of the incoming row are labeled full, all the other leaves are empty. the remaining nodes are labeled as follows.
• empty : all of its children are empty
• full : all of its children are full
• partial : neither full nor empty
– 2. Tree modification
![Page 10: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/10.jpg)
10
1. Node labeling (bottom-up)
• The first time a node u becomes partial or full report to its parent.
• The first time a node u gets a partial or full child label u partial.
• The first time all children of a node u become full label u full.
![Page 11: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/11.jpg)
11
2. Tree modification
• Need to modify the current tree so that all the incoming columns can be arranged consecutively.
• There is no need to do anything for full subtrees• Modify the subtree of every partial node
– At each iteration, modify the subtree T of a partial node starting from the lowest level of the tree
• The purpose is to ensure all full subtrees of T can be arranged consecutively. The subtree modification is based on 9 templates of subtree structures.
![Page 12: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/12.jpg)
12
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 13: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/13.jpg)
13
Template operations
• Change the children order so that full nodes become consecutive.
• Perform this in a bottom-up fashion• At each stage, there are 9 templates to
check altogether– These templates are, in some sense,
minimized.
![Page 14: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/14.jpg)
14
Templates P0 & P1
.......
....... .......
.......
P0 P1
![Page 15: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/15.jpg)
15
......
...
...
Template P2 for ROOT (T,S) when it is a P-node
![Page 16: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/16.jpg)
16
Q-templates for partial nodes other than the root
• If the root is the only partial node, use template P2 in the last slide (so the root remains as a P-node).
• Otherwise, we use Q-node to represent a partial node during the operation so that the Q-templates can be adopted correctly.
![Page 17: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/17.jpg)
17
......
......
Template P3 for a singly partial P-node which is not ROOT (T,S)
Even though this Q-node has only two children, we still
make it a Q-node to facilitate later Q-template operations
![Page 18: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/18.jpg)
18
... ...
... ...
Template P4 for ROOT(T,S) when it is a P-node with one partial child
...... ...
...
![Page 19: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/19.jpg)
19
Template P5 for a singly partial P-node, other than ROOT(T,S), with one partial
child
... ...
... ...
... ...
... ...
![Page 20: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/20.jpg)
20
Template P6 for ROOT(T,S) when it is a doubly partial P-node
......
...
...
... ...
...... ...... ...
![Page 21: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/21.jpg)
21
Templates Q0 & Q1
• Similar to P0 and P1
![Page 22: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/22.jpg)
22
... ......
... ... ......
Template Q2 for a singly partial Q-node
![Page 23: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/23.jpg)
23
Template Q3 for a double partial Q-node
... ...... .........
... ... ... ...
...... ...
![Page 24: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/24.jpg)
24
Time complexity of the original PQ-tree operations
• Because of the frequent change of parent children relations, we can only keep parent pointers for two “end” nodes of each Q-node.
• This analysis of O(m+n) time is quite involved– Booth & Lueker used amortized analysis to argue
that it takes constant time at every iteration.• Details will be given later when we discuss
the complexity of PC-tree operations.
![Page 25: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/25.jpg)
25
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 26: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/26.jpg)
26
Circular Ones Property (CLOP)
• Does there exist a column order such that either – the 1’s in each row are consecutive or – the 0’s in each row are consecutive
• This would be easy to see if you wrap around the column indices in a circle.
![Page 27: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/27.jpg)
27
PC-Trees
• A PC-tree is an un-rooted tree with two types of nodes P and C.
• Neighbors of a P-node can be permuted arbitrarily (Note that here we did not say “children” because there is no specific root).
• Neighbors of a C-node obey a clockwise order, which can only be inverted.
![Page 28: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/28.jpg)
28
PQ-trees → PC-trees
Q1 P
1 2 3
Q2
5 64
1
2
3
5
6
4
Root
C1P
C2
If you consider the order of the parent and children of a Q-node in a cyclic fashion, its clockwise order can only be inverted, which is the spirit of a C-node
![Page 29: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/29.jpg)
29
PC-trees and the circular ones property
PC-trees can record all feasible circular permutations of the column indices
2
P
1 3 5 64
1 2 3 4 5 61 2 3 4 5 6
1 1 0 0 0 01 1 0 0 0 0
0 1 1 0 0 00 1 1 0 0 0
1 1 1 1 0 01 1 1 1 0 0
0 0 0 1 1 10 0 0 1 1 1
1 0 0 0 1 11 0 0 0 1 1 C
C
1, 5, 6 are consecutive
![Page 30: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/30.jpg)
30
Rotation of PC-trees
1 2 3 5 64
CRoot
C P
2 3 5 64
C
C
P
1
Root
The “root” concept is not important for PC-trees. It is there to maintain the parent-children relation for efficiency.
![Page 31: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/31.jpg)
31
PC-trees and the consecutive ones property
PC-trees can also be used to record all feasible permutations for consecutive ones (fix the first column to be 1)
P
1 2 3 5 64
1 2 3 4 5 61 2 3 4 5 6
1 1 0 0 0 01 1 0 0 0 0
0 1 1 0 0 00 1 1 0 0 0
1 1 1 1 0 01 1 1 1 0 0
0 0 0 1 1 10 0 0 1 1 1
C
C
![Page 32: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/32.jpg)
32
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 33: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/33.jpg)
33
The PC-tree algorithm
1. Node labeling• The same as in PQ-tree
2. Tree splitting• Create a new C-node
• Same as PQ-tree, this is also an online algorithm (rows are processed as they are given), but without any templates
![Page 34: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/34.jpg)
34
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 35: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/35.jpg)
35
• Objective: Objective: Find a path that separates the full Find a path that separates the full subtrees from the empty onessubtrees from the empty ones– Sufficient to find the two Sufficient to find the two end nodesend nodes of this path of this path
• A A rootingrooting of a PC-tree is to assign a node as of a PC-tree is to assign a node as the root and redirect all parent-child relationsthe root and redirect all parent-child relations
• Terminal NodeTerminal Node– A partial node whose children are either empty or
full relative to some rooting
Our approach:Finding a separating path
empty full
![Page 36: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/36.jpg)
36
Key observationsKey observations
• There are at most two terminal nodes– There is a unique tree path between these
two nodes• Full children of C-nodes on the path can
be correctly flipped to one side, and empty ones to the other side
![Page 37: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/37.jpg)
37
The unique terminal path between The unique terminal path between two terminal nodes two terminal nodes u, u’ u, u’ (I)(I)
u m u'empty
fullFlippable C-node
RWhat if node u is a C-node?
Case 1. u, u’ and R are not on a path
![Page 38: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/38.jpg)
38
The unique terminal path between The unique terminal path between two terminal nodes two terminal nodes u, u’ u, u’ (II)(II)
u u'
R
empty
full
Case 2. u, u’ and R are on a path
![Page 39: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/39.jpg)
39
Forbidden structures on PC-trees
• Whenever you have such a collection of subtrees, the matrix does not satisfy the CLOP (and hence, does not satisfy the COP).– Why? 1, 3, 5 have to be next to each other.– WLOG, assume the order is 135 where 3 is
between 1 and 5. But then, there is no place for 4, which needs to be to the left or right of 3.
33 44 55 6611 22
Where 1, 3, 5 are distinct and
consecutive
![Page 40: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/40.jpg)
40
Forbidden structures on PC-trees
33 44 55 66
1. Three terminal nodes 2. Non-flippable C-node
11 22Where 1, 3, 5 are distinct
When three parents are on a path
The following two cases are forbidden for matrices satisfying the CLOP
![Page 41: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/41.jpg)
41
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 42: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/42.jpg)
42
The unique terminal path The unique terminal path between two terminal nodesbetween two terminal nodes
u m u'
R
empty
full
![Page 43: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/43.jpg)
43
The path splitting operation
m
i
m
Duplicate each P-node that has both a full subtree and an empty subtree
![Page 44: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/44.jpg)
44
Connecting to the new C-node (I)- using the “full side” as an example
u m u'
• All P-nodes on the path connects directly to the new node– obeying the order on the path
• All C-nodes on the path are deleted. Their children connect directly to the new node– obeying their original order as well as path order
![Page 45: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/45.jpg)
45
Connecting to the new C-node (II)
CP PC C
11 554422 77 88
63
P P
1 542 7 863
![Page 46: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/46.jpg)
A Graphical Illustration of the PQ-Tree Operations vs.
the PC-Tree Operations
For this example, we only demonstrate the flipping process
(but not the merge operation)
![Page 47: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/47.jpg)
47
Template Matching of PQ-trees (I)
P
Q
P
P P
QP
Q
![Page 48: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/48.jpg)
48
Template Matching of PQ-trees (II)
P
Q
P
P P
QP
Q
V
![Page 49: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/49.jpg)
49
What has been accomplished by the flipping ?
P
Q
P
P P
QP
Q
P
Q
P
P P
QP
Q
![Page 50: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/50.jpg)
50
Another look at the result of the flipping operation
m
R
u u’
P
Q
P
P P
QP
Q
![Page 51: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/51.jpg)
51
The corresponding PC-Tree Operation
P4
P1
P3P2
P5
![Page 52: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/52.jpg)
52
LCA: The least common ancestor of full leaves
1. LCA is a full node:
No tree modification necessary
2. LCA is a partial node:A child Q-node is created with the full children arranged consecutively (there can be many cases, one example is shown below)
The PQ-tree after the modification
![Page 53: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/53.jpg)
53
An example for a PC-tree operation equivalent to a template conversion
![Page 54: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/54.jpg)
54
Complexity Analysis• Want to show the cost is proportional to the # of
1’s in the row (i.e. # of full leaves). • There is a catch here: for each C-node, we cannot
afford to have a parent pointer for each child due to frequent pointer change in path splitting. – Can only keep parent pointer for two “end” nodes– Keep a cycle for each C-node as a double linked list– Internal node of the cycle find parent through neighbors!
virtual real
![Page 55: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/55.jpg)
55
The cost of node labeling
• Easy for P-node; for each internal node of a C-node, inform its two neighbors when it becomes full or partial.– Since full children of a C-node must be
consecutive, it is easy to check at the end whether this C-node is full or partial
– In case none of the two end nodes are full, this C-node is the LCA. Nothing else needs to be done (similar to the case that the LCA is full)
![Page 56: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/56.jpg)
56
The cost of path splitting (I)• Instead of connecting the new C-node to
each of its child, go around the boundary of the C-node to form its cycle.
CP PC C
11 554422 77 88
63
P P
1 542 7 863
Each P-node that has both a full subtree and an empty subtree is duplicated
![Page 57: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/57.jpg)
57
Path splitting and the new C-node
The terminal path
The new C-node
Cost = path traversal + # of P-node duplication
![Page 58: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/58.jpg)
58
The cost of path splitting (II)
• Each P-node that has both full subtrees and empty subtrees need to be duplicated– The # of new P-nodes added at each
iteration # of full subtrees• Need to worry about the cost of
traversing through empty P-nodes
![Page 59: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/59.jpg)
59
A potential problem: what if a cycle contains very few full
nodes?• The cost of forming this cycle
(traversing through empty P-nodes in the cycle) is not proportional to the number of full nodes.
u u'
![Page 60: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/60.jpg)
60
Charging the Traversal of empty P-nodes separately
• Every time an empty P-node is traversed in forming a cycle, its two neighboring tree edges become cycle links
• Once a tree edge becomes a cycle link, it remains as a link.– Each tree edge can be converted to a link
at most once!
![Page 61: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/61.jpg)
61
Table of contents
• Review of PQ-trees– Template operations
• Introducing PC-trees• The PC-tree algorithm
– Terminal nodes– Splitting the terminal path
• Observations on PC-trees
![Page 62: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/62.jpg)
62
Final observations (I)
• At every iteration, we determine a unique path that separates the tree into “two parts” (for circular ones, the root is immaterial).
![Page 63: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/63.jpg)
63
Final observations (II)• The two terminal nodes actually give the two “cuts”
in terms of the column partition (when the new row is placed into the current partition).
![Page 64: PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting](https://reader035.vdocument.in/reader035/viewer/2022062905/5a4d1ae87f8b9ab059979db6/html5/thumbnails/64.jpg)
64