mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-22 21:01:50 +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++: data_structures/sparse_table.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');
|
||||
@@ -135,16 +135,16 @@ Namespaces</h2></td></tr>
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
|
||||
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">Self-test implementations. <a href="../../d6/d42/data__structures_2sparse__table_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">Self-test implementations. <br /></td></tr>
|
||||
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a0ddf1224851353fc92bfbff6f499fa97"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">main</a> (int argc, char *argv[])</td></tr>
|
||||
<tr class="memdesc:a0ddf1224851353fc92bfbff6f499fa97"><td class="mdescLeft"> </td><td class="mdescRight">Main function. <a href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:a0ddf1224851353fc92bfbff6f499fa97"><td class="mdescLeft"> </td><td class="mdescRight">Main function. <br /></td></tr>
|
||||
<tr class="separator:a0ddf1224851353fc92bfbff6f499fa97"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="var-members" name="var-members"></a>
|
||||
Variables</h2></td></tr>
|
||||
<tr class="memitem:a10f3ffb3f6f7e1b83d556b9c8de89a5d"><td class="memItemLeft" align="right" valign="top">constexpr uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">data_structures::sparse_table::N</a> = 12345</td></tr>
|
||||
<tr class="memdesc:a10f3ffb3f6f7e1b83d556b9c8de89a5d"><td class="mdescLeft"> </td><td class="mdescRight">A struct to represent sparse table for <code>min()</code> as their invariant function, for the given array <code>A</code>. The answer to queries are stored in the array ST. <a href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:a10f3ffb3f6f7e1b83d556b9c8de89a5d"><td class="mdescLeft"> </td><td class="mdescRight">A struct to represent sparse table for <code>min()</code> as their invariant function, for the given array <code>A</code>. The answer to queries are stored in the array ST. <br /></td></tr>
|
||||
<tr class="separator:a10f3ffb3f6f7e1b83d556b9c8de89a5d"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:af7db62f21983565c64d5d42d2a49888e"><td class="memItemLeft" align="right" valign="top"><a id="af7db62f21983565c64d5d42d2a49888e" name="af7db62f21983565c64d5d42d2a49888e"></a>
|
||||
constexpr uint8_t </td><td class="memItemRight" valign="bottom"><b>data_structures::sparse_table::M</b> = 14</td></tr>
|
||||
@@ -152,10 +152,10 @@ constexpr uint8_t </td><td class="memItemRight" valign="bottom"><b>data_str
|
||||
<tr class="separator:af7db62f21983565c64d5d42d2a49888e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Implementation of <a href="https://brilliant.org/wiki/sparse-table/" target="_blank">Sparse Table</a> for <code>min()</code> function. </p>
|
||||
<div class="textblock"><p>Implementation of <a href="https://brilliant.org/wiki/sparse-table/" target="_blank">Sparse Table</a> for <code>min()</code> function. </p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/manncodes" target="_blank">Mann Patel</a></dd></dl>
|
||||
<p>Sparse Table is a data structure, that allows answering range queries. It can answer most range queries in O(logn), but its true power is answering range minimum queries (or equivalent range maximum queries). For those queries it can compute the answer in O(1) time. The only drawback of this data structure is, that it can only be used on immutable arrays. This means, that the array cannot be changed between two queries.</p>
|
||||
<p >If any element in the array changes, the complete data structure has to be recomputed.</p>
|
||||
<p>If any element in the array changes, the complete data structure has to be recomputed.</p>
|
||||
<dl class="todo"><dt><b><a class="el" href="../../dd/da0/todo.html#_todo000004">Todo:</a></b></dt><dd>make stress tests.</dd></dl>
|
||||
<dl class="section warning"><dt>Warning</dt><dd>This sparse table is made for <code>min(a1,a2,...an)</code> duplicate invariant function. This implementation can be changed to other functions like <code><a class="el" href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd()</a></code>, <code><a class="el" href="../../d4/d21/least__common__multiple_8cpp.html#aa8d0e241db517813725e721a152e3a25">lcm()</a></code>, and <code>max()</code> by changing a few lines of code. </dd></dl>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
@@ -233,15 +233,15 @@ Here is the call graph for this function:</div>
|
||||
|
||||
<p>Self-test implementations. </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
||||
<p >< array on which RMQ will be performed.</p>
|
||||
<p >< size of self test's array</p>
|
||||
<p >< declaring sparse tree</p>
|
||||
<p >< copying array to the struct</p>
|
||||
<p >< passing the array's size to the struct</p>
|
||||
<p >< precomputing sparse tree</p>
|
||||
<p >< as 1 is smallest from 1..9</p>
|
||||
<p >< as 2 is smallest from 2..6</p>
|
||||
<p >< as 3 is smallest from 3..8</p>
|
||||
<p>< array on which RMQ will be performed.</p>
|
||||
<p>< size of self test's array</p>
|
||||
<p>< declaring sparse tree</p>
|
||||
<p>< copying array to the struct</p>
|
||||
<p>< passing the array's size to the struct</p>
|
||||
<p>< precomputing sparse tree</p>
|
||||
<p>< as 1 is smallest from 1..9</p>
|
||||
<p>< as 2 is smallest from 2..6</p>
|
||||
<p>< as 3 is smallest from 3..8</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 128</span> {</div>
|
||||
<div class="line"><span class="lineno"> 129</span> <span class="comment">/* We take an array as an input on which we need to perform the ranged</span></div>
|
||||
<div class="line"><span class="lineno"> 130</span><span class="comment"> * minimum queries[RMQ](https://en.wikipedia.org/wiki/Range_minimum_query).</span></div>
|
||||
@@ -306,7 +306,7 @@ Here is the call graph for this function:</div>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>A struct to represent sparse table for <code>min()</code> as their invariant function, for the given array <code>A</code>. The answer to queries are stored in the array ST. </p>
|
||||
<p >the maximum size of the array. </p>
|
||||
<p>the maximum size of the array. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -316,7 +316,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_2e746e9d06bf2d8ff842208bcc6ebcfc.html">data_structures</a></li><li class="navelem"><a class="el" href="../../d6/d42/data__structures_2sparse__table_8cpp.html">sparse_table.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