Documentation for 0931d530ae

This commit is contained in:
github-actions
2023-01-22 19:44:10 +00:00
parent a448f64699
commit b48f6e8671
2457 changed files with 9513 additions and 8691 deletions

View File

@@ -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++: math/binary_exponent.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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
@@ -120,12 +120,12 @@ Functions</h2></td></tr>
<tr class="memitem:a31dbf5f7ceb9c9eec831ef9f7782291f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/dcf/binary__exponent_8cpp.html#a31dbf5f7ceb9c9eec831ef9f7782291f">binExpo_alt</a> (int a, int b)</td></tr>
<tr class="separator:a31dbf5f7ceb9c9eec831ef9f7782291f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/dcf/binary__exponent_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <a href="../../de/dcf/binary__exponent_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <br /></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >C++ Program to find Binary Exponent Iteratively and Recursively. </p>
<p >Calculate \(a^b\) in \(O(\log(b))\) by converting \(b\) to a binary number. Binary exponentiation is also known as exponentiation by squaring. </p><dl class="section note"><dt>Note</dt><dd>This is a far better approach compared to naive method which provide \(O(b)\) operations.</dd></dl>
<div class="textblock"><p>C++ Program to find Binary Exponent Iteratively and Recursively. </p>
<p>Calculate \(a^b\) in \(O(\log(b))\) by converting \(b\) to a binary number. Binary exponentiation is also known as exponentiation by squaring. </p><dl class="section note"><dt>Note</dt><dd>This is a far better approach compared to naive method which provide \(O(b)\) operations.</dd></dl>
<p>Example: 10 in base 2 is 1010. </p><p class="formulaDsp">
\begin{eqnarray*}
2^{10_d} &amp;=&amp; 2^{1010_b} = 2^8 * 2^2\\
@@ -162,7 +162,7 @@ Functions</h2></td></tr>
</tr>
</table>
</div><div class="memdoc">
<p >Recursive function to calculate exponent in \(O(\log(n))\) using binary exponent. </p>
<p>Recursive function to calculate exponent in \(O(\log(n))\) using binary exponent. </p>
<div class="fragment"><div class="line"><span class="lineno"> 28</span> {</div>
<div class="line"><span class="lineno"> 29</span> <span class="keywordflow">if</span> (b == 0) {</div>
<div class="line"><span class="lineno"> 30</span> <span class="keywordflow">return</span> 1;</div>
@@ -209,7 +209,7 @@ Here is the call graph for this function:</div>
</tr>
</table>
</div><div class="memdoc">
<p >Iterative function to calculate exponent in \(O(\log(n))\) using binary exponent. </p>
<p>Iterative function to calculate exponent in \(O(\log(n))\) using binary exponent. </p>
<div class="fragment"><div class="line"><span class="lineno"> 42</span> {</div>
<div class="line"><span class="lineno"> 43</span> <span class="keywordtype">int</span> res = 1;</div>
<div class="line"><span class="lineno"> 44</span> <span class="keywordflow">while</span> (b &gt; 0) {</div>
@@ -241,10 +241,10 @@ Here is the call graph for this function:</div>
</div><div class="memdoc">
<p>Main function. </p>
<p >Give two numbers a, b</p>
<p >int resIterate = binExpo_alt(a, b);</p>
<p >Result of a^b (where '^' denotes exponentiation)</p>
<p ><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; resIterate &lt;&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</p>
<p>Give two numbers a, b</p>
<p>int resIterate = binExpo_alt(a, b);</p>
<p>Result of a^b (where '^' denotes exponentiation)</p>
<p><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; resIterate &lt;&lt; <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</p>
<div class="fragment"><div class="line"><span class="lineno"> 55</span> {</div>
<div class="line"><span class="lineno"> 56</span> <span class="keywordtype">int</span> a, b;<span class="comment"></span></div>
<div class="line"><span class="lineno"> 57</span><span class="comment"> /// Give two numbers a, b</span></div>
@@ -280,7 +280,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_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../de/dcf/binary__exponent_8cpp.html">binary_exponent.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>