Algorithm——LCA(Least Common Ancestors)
Difference between en4 and en5, changed 4 character(s)
#### 1.introduction↵

As everyone knows, my friend [user:Billy2007,2020-04-16] is not good at The algorithm of tree, So I and he write this blog.↵

LCA , that is, the recent Common ancestor, refers to the root tree, find out one or two nodes u and v recent Common ancestor.↵

#### 2.how to ask LCA?↵

For example:↵

Given a tree with multiple branches, the public ancestor that is closest to the specified two points is requested.↵

The first line contains three positive integers, 
$$$N,M,S$$$ which respectively represent the number of nodes in the tree, the number of inquiries, and the number of root nodes.↵
Next, n-1n-1 rows each contain two positive integers x, yx,y, indicating that there is a directly connected edge between xx node and yy node (the data is guaranteed to form a tree).↵
Next, MM rows each contain two positive integers a, ba, and b, which means that the nearest common ancestor of aa and bb is inquired.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en14 English Inversentropir-36 2020-04-17 08:42:35 0 (published)
en13 English Inversentropir-36 2020-04-17 08:41:41 2
en12 English Inversentropir-36 2020-04-17 08:41:23 34
en11 English Inversentropir-36 2020-04-17 08:40:35 12
en10 English Inversentropir-36 2020-04-17 08:39:51 471
en9 English Inversentropir-36 2020-04-16 16:55:36 131
en8 English Inversentropir-36 2020-04-16 13:28:52 325
en7 English Inversentropir-36 2020-04-16 13:25:09 177
en6 English Inversentropir-36 2020-04-16 13:20:49 55
en5 English Inversentropir-36 2020-04-16 13:16:42 4 Tiny change: 'integers, N,M,SN,M,SN,M,S which res' -> 'integers, $N,M,S$ which res'
en4 English Inversentropir-36 2020-04-16 13:14:05 659
en3 English Inversentropir-36 2020-04-16 13:10:09 2 Tiny change: 'oduction\nAs ever' -> 'oduction\n\nAs ever'
en2 English Inversentropir-36 2020-04-16 13:09:43 213
en1 English Inversentropir-36 2020-04-16 13:06:26 98 Initial revision (saved to drafts)