mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-02 06:22:55 +08:00
Documentation for 0931d530ae
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.5"/>
|
||||
<meta name="generator" content="Doxygen 1.9.6"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: graph/lowest_common_ancestor.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.5 -->
|
||||
<!-- Generated by Doxygen 1.9.6 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
@@ -142,14 +142,14 @@ Functions</h2></td></tr>
|
||||
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Data structure for finding the lowest common ancestor of two vertices in a rooted tree using binary lifting. </p>
|
||||
<p >Algorithm: <a href="https://cp-algorithms.com/graph/lca_binary_lifting.html">https://cp-algorithms.com/graph/lca_binary_lifting.html</a></p>
|
||||
<p >Complexity:</p><ul>
|
||||
<div class="textblock"><p>Data structure for finding the lowest common ancestor of two vertices in a rooted tree using binary lifting. </p>
|
||||
<p>Algorithm: <a href="https://cp-algorithms.com/graph/lca_binary_lifting.html">https://cp-algorithms.com/graph/lca_binary_lifting.html</a></p>
|
||||
<p>Complexity:</p><ul>
|
||||
<li>Precomputation: \(O(N \log N)\) where \(N\) is the number of vertices in the tree</li>
|
||||
<li>Query: \(O(\log N)\)</li>
|
||||
<li>Space: \(O(N \log N)\)</li>
|
||||
</ul>
|
||||
<p >Example: <br />
|
||||
<p>Example: <br />
|
||||
Tree: </p><pre>
|
||||
_ 3 _
|
||||
/ | \
|
||||
@@ -158,12 +158,12 @@ Functions</h2></td></tr>
|
||||
7 5 2 8 0
|
||||
|
|
||||
9
|
||||
</pre><p ><br />
|
||||
</pre><p><br />
|
||||
lowest_common_ancestor(7, 4) = 3 <br />
|
||||
lowest_common_ancestor(9, 6) = 6 <br />
|
||||
lowest_common_ancestor(0, 0) = 0 <br />
|
||||
lowest_common_ancestor(8, 2) = 6</p>
|
||||
<p >The query is symmetrical, therefore lowest_common_ancestor(x, y) = lowest_common_ancestor(y, x) </p>
|
||||
<p>The query is symmetrical, therefore lowest_common_ancestor(x, y) = lowest_common_ancestor(y, x) </p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </a></span>main()</h2>
|
||||
@@ -180,7 +180,7 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Main function </p>
|
||||
<p>Main function </p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 255</span> {</div>
|
||||
<div class="line"><span class="lineno"> 256</span> <a class="code hl_function" href="../../de/dde/lowest__common__ancestor_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>();</div>
|
||||
<div class="line"><span class="lineno"> 257</span> <span class="keywordflow">return</span> 0;</div>
|
||||
@@ -217,7 +217,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Unit tests </p><dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
|
||||
<p>Unit tests </p><dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
|
||||
<pre class="fragment"> _ 3 _
|
||||
/ | \
|
||||
1 6 4
|
||||
@@ -259,7 +259,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_12552d7fa429bf94a2e32e5cf39f7e69.html">graph</a></li><li class="navelem"><a class="el" href="../../de/dde/lowest__common__ancestor_8cpp.html">lowest_common_ancestor.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user