“…To compute count r,r , count r,f , and count f,r , we could preprocess T 1 and T 2 in O(n) time so that lowest common ancestor queries in T 1 and T 2 could be answered in O(1) time [2,12]. Then, for any given a, b ∈ L, a brute-force solution would easily obtain all of count r,r (a, b), count r,f (a, b), and count f,r (a, b) ,r (a, b), count r,f (a, b), and count f,r (a, b) for all a, b ∈ L. In the rest of this section, we show how to obtain these values more efficiently.…”