Documentation for b09b3da69a

This commit is contained in:
github-actions
2020-09-30 18:06:14 +00:00
parent e5c4609582
commit a387c2ff98
198 changed files with 5243 additions and 4512 deletions

331
d6/d10/cut__rod_8cpp.html Normal file
View File

@@ -0,0 +1,331 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: dynamic_programming/cut_rod.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Algorithms_in_C++
&#160;<span id="projectnumber">1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('d6/d10/cut__rod_8cpp.html','../../'); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#namespaces">Namespaces</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">cut_rod.cpp File Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Implementation of cutting a rod problem.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;array&gt;</code><br />
<code>#include &lt;cassert&gt;</code><br />
<code>#include &lt;climits&gt;</code><br />
<code>#include &lt;iostream&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for cut_rod.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d7/da4/cut__rod_8cpp__incl.svg" width="332" height="127"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:dd/d24/namespacedynamic__programming"><td class="memItemLeft" align="right" valign="top"> &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></td></tr>
<tr class="memdesc:dd/d24/namespacedynamic__programming"><td class="mdescLeft">&#160;</td><td class="mdescRight">Dynamic Programming algorithms. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:d8/d36/namespacecut__rod"><td class="memItemLeft" align="right" valign="top"> &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d36/namespacecut__rod.html">cut_rod</a></td></tr>
<tr class="memdesc:d8/d36/namespacecut__rod"><td class="mdescLeft">&#160;</td><td class="mdescRight">Implementation of cutting a rod problem. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ae550b90e6057a7f976c9d643f706c4f5"><td class="memTemplParams" colspan="2">template&lt;size_t T&gt; </td></tr>
<tr class="memitem:ae550b90e6057a7f976c9d643f706c4f5"><td class="memTemplItemLeft" align="right" valign="top">int&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d6/d10/cut__rod_8cpp.html#ae550b90e6057a7f976c9d643f706c4f5">dynamic_programming::cut_rod::maxProfitByCuttingRod</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>&lt; int, T &gt; &amp;price, const int n)</td></tr>
<tr class="memdesc:ae550b90e6057a7f976c9d643f706c4f5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Cuts the rod in different pieces and stores the maximum profit for each piece of the rod. <a href="../../d6/d10/cut__rod_8cpp.html#ae550b90e6057a7f976c9d643f706c4f5">More...</a><br /></td></tr>
<tr class="separator:ae550b90e6057a7f976c9d643f706c4f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to test above algorithm. <a href="../../d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><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="../../d6/d10/cut__rod_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <a href="../../d6/d10/cut__rod_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><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>Implementation of cutting a rod problem. </p>
<p>Given a rod of length n inches and an array of prices that contains prices of all pieces of size&lt;=n. Determine the maximum profit obtainable by cutting up the rod and selling the pieces.</p>
<h3><a class="anchor" id="autotoc_md43"></a>
Algorithm</h3>
<p>The idea is to break the given rod into every smaller piece as possible and then check profit for each piece, by calculating maximum profit for smaller pieces we will build the solution for larger pieces in bottom-up manner.</p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Anmol3299">Anmol</a> </dd>
<dd>
<a href="https://github.com/Pardeep009">Pardeep</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&nbsp;</a></span>main()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; {</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="comment">// Testing</span></div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; <a class="code" href="../../d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160;}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d6/d10/cut__rod_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="274" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ae550b90e6057a7f976c9d643f706c4f5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae550b90e6057a7f976c9d643f706c4f5">&#9670;&nbsp;</a></span>maxProfitByCuttingRod()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;size_t T&gt; </div>
<table class="memname">
<tr>
<td class="memname">int dynamic_programming::cut_rod::maxProfitByCuttingRod </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>&lt; int, T &gt; &amp;&#160;</td>
<td class="paramname"><em>price</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const int&#160;</td>
<td class="paramname"><em>n</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Cuts the rod in different pieces and stores the maximum profit for each piece of the rod. </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
<table class="tparams">
<tr><td class="paramname">T</td><td>size of the price array </td></tr>
</table>
</dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">n</td><td>size of the rod in inches </td></tr>
<tr><td class="paramname">price</td><td>an array of prices that contains prices of all pieces of size&lt;=n </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>maximum profit obtainable for</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">n</td><td>inch rod. </td></tr>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; {</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="keywordtype">int</span> *profit =</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; <span class="keyword">new</span> <span class="keywordtype">int</span>[n + 1]; <span class="comment">// profit[i] will hold maximum profit for i inch rod</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; </div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; profit[0] = 0; <span class="comment">// if length of rod is zero, then no profit</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; </div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; <span class="comment">// outer loop will select size of rod, starting from 1 inch to n inch rod.</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="comment">// inner loop will evaluate the maximum profit we can get for i inch rod by</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; <span class="comment">// making every possible cut on it and will store it in profit[i].</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 1; i &lt;= n; i++) {</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; <span class="keywordtype">int</span> q = INT_MIN;</div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 1; j &lt;= i; j++) {</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; q = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(q, price[j - 1] + profit[i - j]);</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; }</div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; profit[i] = q;</div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; }</div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; <span class="keywordtype">int</span> <a class="code" href="../../d7/d35/matrix__exponentiation_8cpp.html#ad8389ed58fd0ec66df248014775ad1fa">ans</a> = profit[n];</div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; <span class="keyword">delete</span>[] profit;</div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; <span class="keywordflow">return</span> <a class="code" href="../../d7/d35/matrix__exponentiation_8cpp.html#ad8389ed58fd0ec66df248014775ad1fa">ans</a>; <span class="comment">// returning maximum profit</span></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160;}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d6/d10/cut__rod_8cpp_ae550b90e6057a7f976c9d643f706c4f5_cgraph.svg" width="351" height="95"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="aa8dca7b867074164d5f45b0f3851269d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">&#9670;&nbsp;</a></span>test()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static void test </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to test above algorithm. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; {</div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <span class="comment">// Test 1</span></div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> n1 = 8; <span class="comment">// size of rod</span></div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n1&gt;</a> price1 = {1, 5, 8, 9, 10, 17, 17, 20}; <span class="comment">// price array</span></div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> max_profit1 =</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <a class="code" href="../../d6/d10/cut__rod_8cpp.html#ae550b90e6057a7f976c9d643f706c4f5">dynamic_programming::cut_rod::maxProfitByCuttingRod</a>(price1, n1);</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> expected_max_profit1 = 22;</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; assert(max_profit1 == expected_max_profit1);</div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Maximum profit with &quot;</span> &lt;&lt; n1 &lt;&lt; <span class="stringliteral">&quot; inch road is &quot;</span> &lt;&lt; max_profit1</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; &lt;&lt; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; </div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; <span class="comment">// Test 2</span></div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> n2 = 30; <span class="comment">// size of rod</span></div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n2&gt;</a> price2 = {</div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; 1, 5, 8, 9, 10, 17, 17, 20, 24, 30, <span class="comment">// price array</span></div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; 41, 42, 43, 44, 45, 46, 47, 48, 49, 50};</div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> max_profit2 =</div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; <a class="code" href="../../d6/d10/cut__rod_8cpp.html#ae550b90e6057a7f976c9d643f706c4f5">dynamic_programming::cut_rod::maxProfitByCuttingRod</a>(price2, n2);</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> expected_max_profit2 = 90;</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; assert(max_profit2 == expected_max_profit2);</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Maximum profit with &quot;</span> &lt;&lt; n2 &lt;&lt; <span class="stringliteral">&quot; inch road is &quot;</span> &lt;&lt; max_profit2</div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; &lt;&lt; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160;}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d6/d10/cut__rod_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="175" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div class="ttc" id="amatrix__exponentiation_8cpp_html_ad8389ed58fd0ec66df248014775ad1fa"><div class="ttname"><a href="../../d7/d35/matrix__exponentiation_8cpp.html#ad8389ed58fd0ec66df248014775ad1fa">ans</a></div><div class="ttdeci">ll ans(ll n)</div><div class="ttdef"><b>Definition:</b> matrix_exponentiation.cpp:91</div></div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="aarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a></div><div class="ttdoc">STL class.</div></div>
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
<div class="ttc" id="amax_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a></div><div class="ttdeci">T max(T... args)</div></div>
<div class="ttc" id="acut__rod_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Function to test above algorithm.</div><div class="ttdef"><b>Definition:</b> cut_rod.cpp:71</div></div>
<div class="ttc" id="acut__rod_8cpp_html_ae550b90e6057a7f976c9d643f706c4f5"><div class="ttname"><a href="../../d6/d10/cut__rod_8cpp.html#ae550b90e6057a7f976c9d643f706c4f5">dynamic_programming::cut_rod::maxProfitByCuttingRod</a></div><div class="ttdeci">int maxProfitByCuttingRod(const std::array&lt; int, T &gt; &amp;price, const int n)</div><div class="ttdoc">Cuts the rod in different pieces and stores the maximum profit for each piece of the rod.</div><div class="ttdef"><b>Definition:</b> cut_rod.cpp:44</div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_8a20dd5bfd5341a725342bf72b6b686f.html">dynamic_programming</a></li><li class="navelem"><a class="el" href="../../d6/d10/cut__rod_8cpp.html">cut_rod.cpp</a></li>
<li class="footer">Generated by <a href="http://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20 </li>
</ul>
</div>
</body>
</html>

6
d6/d10/cut__rod_8cpp.js Normal file
View File

@@ -0,0 +1,6 @@
var cut__rod_8cpp =
[
[ "main", "d6/d10/cut__rod_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ],
[ "maxProfitByCuttingRod", "d6/d10/cut__rod_8cpp.html#ae550b90e6057a7f976c9d643f706c4f5", null ],
[ "test", "d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ]
];

View File

@@ -0,0 +1,4 @@
<map id="test" name="test">
<area shape="rect" id="node1" title="Function to test above algorithm." alt="" coords="5,5,49,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="97,5,169,32"/>
</map>

View File

@@ -0,0 +1 @@
64c90610e30b3ab35b411975a63245fd

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.44.1 (20200629.0846)
-->
<!-- Title: test Pages: 1 -->
<svg width="131pt" height="28pt"
viewBox="0.00 0.00 131.00 28.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 24)">
<title>test</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-24 127,-24 127,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Function to test above algorithm.">
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-19.5 33,-19.5 33,-0.5 0,-0.5"/>
<text text-anchor="middle" x="16.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">test</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" target="_top" xlink:title=" ">
<polygon fill="white" stroke="black" points="69,-0.5 69,-19.5 123,-19.5 123,-0.5 69,-0.5"/>
<text text-anchor="middle" x="96" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M33.18,-10C40.64,-10 49.89,-10 58.94,-10"/>
<polygon fill="midnightblue" stroke="midnightblue" points="58.96,-13.5 68.96,-10 58.96,-6.5 58.96,-13.5"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,5 @@
<map id="dynamic_programming::cut_rod::maxProfitByCuttingRod" name="dynamic_programming::cut_rod::maxProfitByCuttingRod">
<area shape="rect" id="node1" title="Cuts the rod in different pieces and stores the maximum profit for each piece of the rod." alt="" coords="5,29,224,71"/>
<area shape="rect" id="node2" href="$d7/d35/matrix__exponentiation_8cpp.html#ad8389ed58fd0ec66df248014775ad1fa" title=" " alt="" coords="287,11,330,38"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/max.html#" title=" " alt="" coords="272,62,345,89"/>
</map>

View File

@@ -0,0 +1 @@
5289fa9c8933322b1fdd4c8db26e23fb

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.44.1 (20200629.0846)
-->
<!-- Title: dynamic_programming::cut_rod::maxProfitByCuttingRod Pages: 1 -->
<svg width="263pt" height="71pt"
viewBox="0.00 0.00 263.00 70.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 66.5)">
<title>dynamic_programming::cut_rod::maxProfitByCuttingRod</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-66.5 259,-66.5 259,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Cuts the rod in different pieces and stores the maximum profit for each piece of the rod.">
<polygon fill="#bfbfbf" stroke="black" points="0,-14 0,-44 164,-44 164,-14 0,-14"/>
<text text-anchor="start" x="8" y="-32" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
<text text-anchor="middle" x="82" y="-21" font-family="Helvetica,sans-Serif" font-size="10.00">::cut_rod::maxProfitByCuttingRod</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node1 -->
<g id="edge3" class="edge">
<title>Node1&#45;&gt;Node1</title>
<path fill="none" stroke="midnightblue" d="M56.91,-44.16C50.85,-53.56 59.22,-62.5 82,-62.5 95.88,-62.5 104.41,-59.18 107.59,-54.46"/>
<polygon fill="midnightblue" stroke="midnightblue" points="111.07,-53.98 107.09,-44.16 104.08,-54.31 111.07,-53.98"/>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a xlink:href="../../d7/d35/matrix__exponentiation_8cpp.html#ad8389ed58fd0ec66df248014775ad1fa" target="_top" xlink:title=" ">
<polygon fill="white" stroke="black" points="211.5,-38.5 211.5,-57.5 243.5,-57.5 243.5,-38.5 211.5,-38.5"/>
<text text-anchor="middle" x="227.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">ans</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M164.39,-39.78C177.73,-41.54 190.61,-43.25 201.15,-44.64"/>
<polygon fill="midnightblue" stroke="midnightblue" points="200.84,-48.13 211.21,-45.98 201.75,-41.19 200.84,-48.13"/>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max.html#" target="_top" xlink:title=" ">
<polygon fill="white" stroke="black" points="200,-0.5 200,-19.5 255,-19.5 255,-0.5 200,-0.5"/>
<text text-anchor="middle" x="227.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::max</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node3 -->
<g id="edge2" class="edge">
<title>Node1&#45;&gt;Node3</title>
<path fill="none" stroke="midnightblue" d="M164.39,-18.22C173.28,-17.05 181.96,-15.9 189.89,-14.85"/>
<polygon fill="midnightblue" stroke="midnightblue" points="190.37,-18.31 199.82,-13.53 189.45,-11.38 190.37,-18.31"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -0,0 +1,5 @@
<map id="main" name="main">
<area shape="rect" id="node1" title="Main function." alt="" coords="5,5,56,32"/>
<area shape="rect" id="node2" href="$d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" title="Function to test above algorithm." alt="" coords="104,5,148,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="196,5,268,32"/>
</map>

View File

@@ -0,0 +1 @@
d6d6e3a0d0edfc1b2ca9e27fc8659655

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.44.1 (20200629.0846)
-->
<!-- Title: main Pages: 1 -->
<svg width="205pt" height="28pt"
viewBox="0.00 0.00 205.00 28.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 24)">
<title>main</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-24 201,-24 201,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Main function.">
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-19.5 38,-19.5 38,-0.5 0,-0.5"/>
<text text-anchor="middle" x="19" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a xlink:href="../../d6/d10/cut__rod_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" target="_top" xlink:title="Function to test above algorithm.">
<polygon fill="white" stroke="black" points="74,-0.5 74,-19.5 107,-19.5 107,-0.5 74,-0.5"/>
<text text-anchor="middle" x="90.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">test</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M38.26,-10C46.07,-10 55.31,-10 63.79,-10"/>
<polygon fill="midnightblue" stroke="midnightblue" points="63.95,-13.5 73.95,-10 63.95,-6.5 63.95,-13.5"/>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" target="_top" xlink:title=" ">
<polygon fill="white" stroke="black" points="143,-0.5 143,-19.5 197,-19.5 197,-0.5 143,-0.5"/>
<text text-anchor="middle" x="170" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2" class="edge">
<title>Node2&#45;&gt;Node3</title>
<path fill="none" stroke="midnightblue" d="M107.18,-10C114.64,-10 123.89,-10 132.94,-10"/>
<polygon fill="midnightblue" stroke="midnightblue" points="132.96,-13.5 142.96,-10 132.96,-6.5 132.96,-13.5"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB