Lowest Common Ancestor with Linking Roots: Difference between revisions

From Algorithm Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 13: Line 13:
== Parameters ==  
== Parameters ==  


n: number of vertices
$n$: number of vertices


m: number of total number of operations (queries, links, and cuts)
$m$: number of total number of operations (queries, links, and cuts)


== Table of Algorithms ==  
== Table of Algorithms ==  

Latest revision as of 10:09, 28 April 2023

Description

Given a collection of rooted trees, answer queries of the form, "What is the nearest common ancestor of vertices $x$ and $y$?" In this version of the problem, The queries are given on-line. Interspersed with the queries are on-line commands of the form $link(x, y)$ where $x$ and $y$ are tree roots. The effect of a command $link(x, y)$ is to combine the trees containing $x$ and $y$ by making $x$ the parent of $y$.

Related Problems

Generalizations: Lowest Common Ancestor

Related: Off-Line Lowest Common Ancestor, Lowest Common Ancestor with Static Trees, Lowest Common Ancestor with Linking, Lowest Common Ancestors with Linking and Cutting

Parameters

$n$: number of vertices

$m$: number of total number of operations (queries, links, and cuts)

Table of Algorithms

Name Year Time Space Approximation Factor Model Reference
Modified van Leeuwen (Linking Roots) 1976 $O(n+m*log(log(n)$)) $O(n)$ Exact Deterministic Space
Harel, Tarjan (Linking Roots) 1984 $O(n+ m*alpha(m + n, n)$) where alpha is the inverse Ackermann function $O(n)$ Exact Deterministic Time & Space