Documentation for 8b1eab204b
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!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" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: dynamic_programming/unbounded_0_1_knapsack.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: dynamic_programming/unbounded_0_1_knapsack.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<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>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<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 type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</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>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -122,7 +139,9 @@ Include dependency graph for unbounded_0_1_knapsack.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/d85/unbounded__0__1__knapsack_8cpp__incl.svg" width="336" height="126"><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">
|
||||
</div>
|
||||
<p><a href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
|
||||
Namespaces</h2></td></tr>
|
||||
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></td></tr>
|
||||
@@ -134,10 +153,10 @@ Namespaces</h2></td></tr>
|
||||
</table><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:afe447a5979582174908695952c8a079c" id="r_afe447a5979582174908695952c8a079c"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> i, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &val, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &wt, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< int > > &dp)</td></tr>
|
||||
<tr class="memitem:afe447a5979582174908695952c8a079c" id="r_afe447a5979582174908695952c8a079c"><td class="memItemLeft" align="right" valign="top">std::uint16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a> (std::uint16_t i, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt, std::vector< std::vector< int > > &dp)</td></tr>
|
||||
<tr class="memdesc:afe447a5979582174908695952c8a079c"><td class="mdescLeft"> </td><td class="mdescRight">Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach. <br /></td></tr>
|
||||
<tr class="separator:afe447a5979582174908695952c8a079c"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a1bcff7f76de48fa7f629480f8f18b5ef" id="r_a1bcff7f76de48fa7f629480f8f18b5ef"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &val, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &wt)</td></tr>
|
||||
<tr class="memitem:a1bcff7f76de48fa7f629480f8f18b5ef" id="r_a1bcff7f76de48fa7f629480f8f18b5ef"><td class="memItemLeft" align="right" valign="top">std::uint16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a> (std::uint16_t N, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt)</td></tr>
|
||||
<tr class="memdesc:a1bcff7f76de48fa7f629480f8f18b5ef"><td class="mdescLeft"> </td><td class="mdescRight">Wrapper function to initiate the unbounded knapsack calculation. <br /></td></tr>
|
||||
<tr class="separator:a1bcff7f76de48fa7f629480f8f18b5ef"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a483bb8ccf42aaf7375a83e91490eda1e" id="r_a483bb8ccf42aaf7375a83e91490eda1e"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a> ()</td></tr>
|
||||
@@ -157,6 +176,8 @@ Algorithm</h3>
|
||||
<p>The approach uses dynamic programming to build a solution iteratively. A 2D array is used for memoization to store intermediate results, allowing the function to avoid redundant calculations.</p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/yeolesanskruti" target="_blank">Sanskruti Yeole</a> </dd></dl>
|
||||
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../db/d16/0__1__knapsack_8cpp.html" title="Implementation of [0-1 Knapsack Problem] (https://en.wikipedia.org/wiki/Knapsack_problem)">dynamic_programming/0_1_knapsack.cpp</a> </dd></dl>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html">unbounded_0_1_knapsack.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="afe447a5979582174908695952c8a079c" name="afe447a5979582174908695952c8a079c"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#afe447a5979582174908695952c8a079c">◆ </a></span>KnapSackFilling()</h2>
|
||||
@@ -165,29 +186,29 @@ Algorithm</h3>
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> dynamic_programming::unbounded_knapsack::KnapSackFilling </td>
|
||||
<td class="memname">std::uint16_t dynamic_programming::unbounded_knapsack::KnapSackFilling </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a></td> <td class="paramname"><span class="paramname"><em>i</em></span>, </td>
|
||||
<td class="paramtype">std::uint16_t</td> <td class="paramname"><span class="paramname"><em>i</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a></td> <td class="paramname"><span class="paramname"><em>W</em></span>, </td>
|
||||
<td class="paramtype">std::uint16_t</td> <td class="paramname"><span class="paramname"><em>W</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &</td> <td class="paramname"><span class="paramname"><em>val</em></span>, </td>
|
||||
<td class="paramtype">const std::vector< std::uint16_t > &</td> <td class="paramname"><span class="paramname"><em>val</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &</td> <td class="paramname"><span class="paramname"><em>wt</em></span>, </td>
|
||||
<td class="paramtype">const std::vector< std::uint16_t > &</td> <td class="paramname"><span class="paramname"><em>wt</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< int > > &</td> <td class="paramname"><span class="paramname"><em>dp</em></span> )</td>
|
||||
<td class="paramtype">std::vector< std::vector< int > > &</td> <td class="paramname"><span class="paramname"><em>dp</em></span> )</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -216,6 +237,8 @@ Algorithm</h3>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>The maximum value that can be obtained for the given index and capacity. </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00058">58</a> of file <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html">unbounded_0_1_knapsack.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 61</span> {</div>
|
||||
<div class="line"><span class="lineno"> 62</span> <span class="keywordflow">if</span> (i == 0) {</div>
|
||||
<div class="line"><span class="lineno"> 63</span> <span class="keywordflow">if</span> (wt[0] <= W) {</div>
|
||||
@@ -236,17 +259,11 @@ Algorithm</h3>
|
||||
<div class="line"><span class="lineno"> 78</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value taking item i</span></div>
|
||||
<div class="line"><span class="lineno"> 79</span> }</div>
|
||||
<div class="line"><span class="lineno"> 80</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] =</div>
|
||||
<div class="line"><span class="lineno"> 81</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(take, nottake); <span class="comment">// Store and return the maximum value</span></div>
|
||||
<div class="line"><span class="lineno"> 81</span> std::max(take, nottake); <span class="comment">// Store and return the maximum value</span></div>
|
||||
<div class="line"><span class="lineno"> 82</span>}</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="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> partition_problem.cpp:39</div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_afe447a5979582174908695952c8a079c"><div class="ttname"><a href="#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a></div><div class="ttdeci">std::uint16_t KnapSackFilling(std::uint16_t i, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt, std::vector< std::vector< int > > &dp)</div><div class="ttdoc">Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:58</div></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="../../d9/dec/unbounded__0__1__knapsack_8cpp_afe447a5979582174908695952c8a079c_cgraph.svg" width="287" height="91"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> <a href="../../de/d8c/partition__problem_8cpp_source.html#l00039">partition_problem.cpp:39</a></div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_afe447a5979582174908695952c8a079c"><div class="ttname"><a href="#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a></div><div class="ttdeci">std::uint16_t KnapSackFilling(std::uint16_t i, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt, std::vector< std::vector< int > > &dp)</div><div class="ttdoc">Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00058">unbounded_0_1_knapsack.cpp:58</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
@@ -266,17 +283,14 @@ Here is the call graph for this function:</div>
|
||||
|
||||
<p>main function </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>0 on successful exit </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00170">170</a> of file <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html">unbounded_0_1_knapsack.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 170</span> {</div>
|
||||
<div class="line"><span class="lineno"> 171</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// Run self test implementation</span></div>
|
||||
<div class="line"><span class="lineno"> 172</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 173</span>}</div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">self test implementation</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:111</div></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="../../d9/dec/unbounded__0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="278" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">self test implementation</div><div class="ttdef"><b>Definition</b> <a href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00111">unbounded_0_1_knapsack.cpp:111</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="a483bb8ccf42aaf7375a83e91490eda1e" name="a483bb8ccf42aaf7375a83e91490eda1e"></a>
|
||||
@@ -304,71 +318,64 @@ Here is the call graph for this function:</div>
|
||||
|
||||
<p>self test implementation </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00111">111</a> of file <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html">unbounded_0_1_knapsack.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 111</span> {</div>
|
||||
<div class="line"><span class="lineno"> 112</span> <span class="comment">// Test Case 1</span></div>
|
||||
<div class="line"><span class="lineno"> 113</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N1 = 4; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 114</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> wt1 = {1, 3, 4, 5}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 115</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> val1 = {6, 1, 7, 7}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W1 = 8; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 113</span> std::uint16_t N1 = 4; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 114</span> std::vector<std::uint16_t> wt1 = {1, 3, 4, 5}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 115</span> std::vector<std::uint16_t> val1 = {6, 1, 7, 7}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 116</span> std::uint16_t W1 = 8; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 117</span> <span class="comment">// Test the function and assert the expected output</span></div>
|
||||
<div class="line"><span class="lineno"> 118</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><span class="lineno"> 119</span> N1, W1, val1, wt1) == 48);</div>
|
||||
<div class="line"><span class="lineno"> 120</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><span class="lineno"> 120</span> std::cout << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><span class="lineno"> 121</span> << <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
|
||||
<div class="line"><span class="lineno"> 122</span> N1, W1, val1, wt1)</div>
|
||||
<div class="line"><span class="lineno"> 123</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 123</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 124</span> </div>
|
||||
<div class="line"><span class="lineno"> 125</span> <span class="comment">// Test Case 2</span></div>
|
||||
<div class="line"><span class="lineno"> 126</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N2 = 3; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 127</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> wt2 = {10, 20, 30}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 128</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> val2 = {60, 100, 120}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 129</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W2 = 5; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 126</span> std::uint16_t N2 = 3; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 127</span> std::vector<std::uint16_t> wt2 = {10, 20, 30}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 128</span> std::vector<std::uint16_t> val2 = {60, 100, 120}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 129</span> std::uint16_t W2 = 5; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 130</span> <span class="comment">// Test the function and assert the expected output</span></div>
|
||||
<div class="line"><span class="lineno"> 131</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><span class="lineno"> 132</span> N2, W2, val2, wt2) == 0);</div>
|
||||
<div class="line"><span class="lineno"> 133</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><span class="lineno"> 133</span> std::cout << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><span class="lineno"> 134</span> << <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
|
||||
<div class="line"><span class="lineno"> 135</span> N2, W2, val2, wt2)</div>
|
||||
<div class="line"><span class="lineno"> 136</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 136</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 137</span> </div>
|
||||
<div class="line"><span class="lineno"> 138</span> <span class="comment">// Test Case 3</span></div>
|
||||
<div class="line"><span class="lineno"> 139</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N3 = 3; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 140</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> wt3 = {2, 4, 6}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 141</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> val3 = {5, 11, 13}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 142</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W3 = 27; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 139</span> std::uint16_t N3 = 3; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 140</span> std::vector<std::uint16_t> wt3 = {2, 4, 6}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 141</span> std::vector<std::uint16_t> val3 = {5, 11, 13}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 142</span> std::uint16_t W3 = 27; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 143</span> <span class="comment">// Test the function and assert the expected output</span></div>
|
||||
<div class="line"><span class="lineno"> 144</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><span class="lineno"> 145</span> N3, W3, val3, wt3) == 27);</div>
|
||||
<div class="line"><span class="lineno"> 146</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><span class="lineno"> 146</span> std::cout << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><span class="lineno"> 147</span> << <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
|
||||
<div class="line"><span class="lineno"> 148</span> N3, W3, val3, wt3)</div>
|
||||
<div class="line"><span class="lineno"> 149</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 149</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 150</span> </div>
|
||||
<div class="line"><span class="lineno"> 151</span> <span class="comment">// Test Case 4</span></div>
|
||||
<div class="line"><span class="lineno"> 152</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N4 = 0; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 153</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> wt4 = {}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 154</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::uint16_t></a> val4 = {}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 155</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W4 = 10; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 152</span> std::uint16_t N4 = 0; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><span class="lineno"> 153</span> std::vector<std::uint16_t> wt4 = {}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 154</span> std::vector<std::uint16_t> val4 = {}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><span class="lineno"> 155</span> std::uint16_t W4 = 10; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><span class="lineno"> 156</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><span class="lineno"> 157</span> N4, W4, val4, wt4) == 0);</div>
|
||||
<div class="line"><span class="lineno"> 158</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Maximum Knapsack value for empty arrays: "</span></div>
|
||||
<div class="line"><span class="lineno"> 158</span> std::cout << <span class="stringliteral">"Maximum Knapsack value for empty arrays: "</span></div>
|
||||
<div class="line"><span class="lineno"> 159</span> << <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
|
||||
<div class="line"><span class="lineno"> 160</span> N4, W4, val4, wt4)</div>
|
||||
<div class="line"><span class="lineno"> 161</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 161</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 162</span> </div>
|
||||
<div class="line"><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"All test cases passed!"</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 163</span> std::cout << <span class="stringliteral">"All test cases passed!"</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 164</span>}</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="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="ainteger_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a></div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a1bcff7f76de48fa7f629480f8f18b5ef"><div class="ttname"><a href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a></div><div class="ttdeci">std::uint16_t unboundedKnapsack(std::uint16_t N, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt)</div><div class="ttdoc">Wrapper function to initiate the unbounded knapsack calculation.</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:93</div></div>
|
||||
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></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="../../d9/dec/unbounded__0__1__knapsack_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg" width="180" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a1bcff7f76de48fa7f629480f8f18b5ef"><div class="ttname"><a href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a></div><div class="ttdeci">std::uint16_t unboundedKnapsack(std::uint16_t N, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt)</div><div class="ttdoc">Wrapper function to initiate the unbounded knapsack calculation.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00093">unbounded_0_1_knapsack.cpp:93</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="a1bcff7f76de48fa7f629480f8f18b5ef" name="a1bcff7f76de48fa7f629480f8f18b5ef"></a>
|
||||
@@ -378,24 +385,24 @@ Here is the call graph for this function:</div>
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> dynamic_programming::unbounded_knapsack::unboundedKnapsack </td>
|
||||
<td class="memname">std::uint16_t dynamic_programming::unbounded_knapsack::unboundedKnapsack </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a></td> <td class="paramname"><span class="paramname"><em>N</em></span>, </td>
|
||||
<td class="paramtype">std::uint16_t</td> <td class="paramname"><span class="paramname"><em>N</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a></td> <td class="paramname"><span class="paramname"><em>W</em></span>, </td>
|
||||
<td class="paramtype">std::uint16_t</td> <td class="paramname"><span class="paramname"><em>W</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &</td> <td class="paramname"><span class="paramname"><em>val</em></span>, </td>
|
||||
<td class="paramtype">const std::vector< std::uint16_t > &</td> <td class="paramname"><span class="paramname"><em>val</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>< <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> > &</td> <td class="paramname"><span class="paramname"><em>wt</em></span> )</td>
|
||||
<td class="paramtype">const std::vector< std::uint16_t > &</td> <td class="paramname"><span class="paramname"><em>wt</em></span> )</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -411,19 +418,16 @@ Here is the call graph for this function:</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>The maximum value that can be obtained for the given capacity. </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html#l00093">93</a> of file <a class="el" href="../../d9/dec/unbounded__0__1__knapsack_8cpp_source.html">unbounded_0_1_knapsack.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 95</span> {</div>
|
||||
<div class="line"><span class="lineno"> 96</span> <span class="keywordflow">if</span> (N == 0)</div>
|
||||
<div class="line"><span class="lineno"> 97</span> <span class="keywordflow">return</span> 0; <span class="comment">// Expect 0 since no items</span></div>
|
||||
<div class="line"><span class="lineno"> 98</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<int></a>> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
|
||||
<div class="line"><span class="lineno"> 99</span> N, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<int></a>(W + 1, -1)); <span class="comment">// Initialize memoization table</span></div>
|
||||
<div class="line"><span class="lineno"> 98</span> std::vector<std::vector<int>> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
|
||||
<div class="line"><span class="lineno"> 99</span> N, std::vector<int>(W + 1, -1)); <span class="comment">// Initialize memoization table</span></div>
|
||||
<div class="line"><span class="lineno"> 100</span> <span class="keywordflow">return</span> <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(N - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Start the calculation</span></div>
|
||||
<div class="line"><span class="lineno"> 101</span>}</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="../../d9/dec/unbounded__0__1__knapsack_8cpp_a1bcff7f76de48fa7f629480f8f18b5ef_cgraph.svg" width="490" height="91"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<map id="dynamic_programming::unbounded_knapsack::unboundedKnapsack" name="dynamic_programming::unbounded_knapsack::unboundedKnapsack">
|
||||
<area shape="rect" id="Node000001" title="Wrapper function to initiate the unbounded knapsack calculation." alt="" coords="5,29,161,85"/>
|
||||
<area shape="poly" id="edge4_Node000001_Node000001" title=" " alt="" coords="43,29,43,19,51,10,64,5,83,3,105,5,118,12,115,17,103,10,83,8,65,10,54,15,48,21,48,29"/>
|
||||
<area shape="rect" id="Node000002" href="$d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c" title="Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach." alt="" coords="209,29,364,85"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="161,54,193,54,193,60,161,60"/>
|
||||
<area shape="poly" id="edge2_Node000002_Node000002" title=" " alt="" coords="254,29,254,19,260,10,271,5,286,3,303,5,314,12,311,16,302,10,286,8,272,10,264,14,259,21,259,29"/>
|
||||
<area shape="rect" id="Node000003" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/max.html#" title=" " alt="" coords="412,44,484,70"/>
|
||||
<area shape="poly" id="edge3_Node000002_Node000003" title=" " alt="" coords="364,54,396,54,396,60,364,60"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
2ea70cc9a7326aa2107dae6f120e7207
|
||||
@@ -1,105 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: dynamic_programming::unbounded_knapsack::unboundedKnapsack Pages: 1 -->
|
||||
<svg width="367pt" height="68pt"
|
||||
viewBox="0.00 0.00 367.25 67.75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 63.75)">
|
||||
<title>dynamic_programming::unbounded_knapsack::unboundedKnapsack</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Wrapper function to initiate the unbounded knapsack calculation.">
|
||||
<polygon fill="#999999" stroke="#666666" points="116.5,-41.75 0,-41.75 0,0 116.5,0 116.5,-41.75"/>
|
||||
<text text-anchor="start" x="8" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
|
||||
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">::unbounded_knapsack</text>
|
||||
<text text-anchor="middle" x="58.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::unboundedKnapsack</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node1 -->
|
||||
<g id="edge4_Node000001_Node000001" class="edge">
|
||||
<title>Node1->Node1</title>
|
||||
<g id="a_edge4_Node000001_Node000001"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M30.1,-42.07C27.42,-51.55 36.8,-59.75 58.25,-59.75 70.65,-59.75 79.01,-57.01 83.35,-52.86"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="86.64,-54.1 85.99,-43.52 79.9,-52.2 86.64,-54.1"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c" target="_top" xlink:title="Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.">
|
||||
<polygon fill="white" stroke="#666666" points="269,-41.75 152.5,-41.75 152.5,0 269,0 269,-41.75"/>
|
||||
<text text-anchor="start" x="160.5" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
|
||||
<text text-anchor="start" x="160.5" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">::unbounded_knapsack</text>
|
||||
<text text-anchor="middle" x="210.75" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::KnapSackFilling</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M116.58,-20.88C124.48,-20.88 132.67,-20.88 140.75,-20.88"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="140.57,-24.38 150.57,-20.88 140.57,-17.38 140.57,-24.38"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node2 -->
|
||||
<g id="edge2_Node000002_Node000002" class="edge">
|
||||
<title>Node2->Node2</title>
|
||||
<g id="a_edge2_Node000002_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M188.35,-42.07C186.21,-51.55 193.68,-59.75 210.75,-59.75 220.35,-59.75 226.91,-57.16 230.44,-53.2"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="233.83,-54.08 232.79,-43.54 227.03,-52.43 233.83,-54.08"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="359.25,-30.5 305,-30.5 305,-11.25 359.25,-11.25 359.25,-30.5"/>
|
||||
<text text-anchor="middle" x="332.12" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::max</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge3_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge3_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M269.34,-20.88C277.48,-20.88 285.67,-20.88 293.3,-20.88"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="293.25,-24.38 303.25,-20.88 293.25,-17.38 293.25,-24.38"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.8 KiB |
@@ -1,79 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: dynamic_programming::unbounded_knapsack::unboundedKnapsack Pages: 1 -->
|
||||
<svg width="367pt" height="68pt"
|
||||
viewBox="0.00 0.00 367.25 67.75" 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 63.75)">
|
||||
<title>dynamic_programming::unbounded_knapsack::unboundedKnapsack</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Wrapper function to initiate the unbounded knapsack calculation.">
|
||||
<polygon fill="#999999" stroke="#666666" points="116.5,-41.75 0,-41.75 0,0 116.5,0 116.5,-41.75"/>
|
||||
<text text-anchor="start" x="8" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
|
||||
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">::unbounded_knapsack</text>
|
||||
<text text-anchor="middle" x="58.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::unboundedKnapsack</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node1 -->
|
||||
<g id="edge4_Node000001_Node000001" class="edge">
|
||||
<title>Node1->Node1</title>
|
||||
<g id="a_edge4_Node000001_Node000001"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M30.1,-42.07C27.42,-51.55 36.8,-59.75 58.25,-59.75 70.65,-59.75 79.01,-57.01 83.35,-52.86"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="86.64,-54.1 85.99,-43.52 79.9,-52.2 86.64,-54.1"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c" target="_top" xlink:title="Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.">
|
||||
<polygon fill="white" stroke="#666666" points="269,-41.75 152.5,-41.75 152.5,0 269,0 269,-41.75"/>
|
||||
<text text-anchor="start" x="160.5" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
|
||||
<text text-anchor="start" x="160.5" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">::unbounded_knapsack</text>
|
||||
<text text-anchor="middle" x="210.75" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::KnapSackFilling</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M116.58,-20.88C124.48,-20.88 132.67,-20.88 140.75,-20.88"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="140.57,-24.38 150.57,-20.88 140.57,-17.38 140.57,-24.38"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node2 -->
|
||||
<g id="edge2_Node000002_Node000002" class="edge">
|
||||
<title>Node2->Node2</title>
|
||||
<g id="a_edge2_Node000002_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M188.35,-42.07C186.21,-51.55 193.68,-59.75 210.75,-59.75 220.35,-59.75 226.91,-57.16 230.44,-53.2"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="233.83,-54.08 232.79,-43.54 227.03,-52.43 233.83,-54.08"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="359.25,-30.5 305,-30.5 305,-11.25 359.25,-11.25 359.25,-30.5"/>
|
||||
<text text-anchor="middle" x="332.12" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::max</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge3_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge3_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M269.34,-20.88C277.48,-20.88 285.67,-20.88 293.3,-20.88"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="293.25,-24.38 303.25,-20.88 293.25,-17.38 293.25,-24.38"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.1 KiB |
@@ -1,5 +0,0 @@
|
||||
<map id="tests" name="tests">
|
||||
<area shape="rect" id="Node000001" title="self test implementation" alt="" coords="5,5,56,31"/>
|
||||
<area shape="rect" id="Node000002" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="104,5,175,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="56,16,88,16,88,21,56,21"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
3f7143541dfbea83ed597655d04aca76
|
||||
@@ -1,65 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: tests Pages: 1 -->
|
||||
<svg width="135pt" height="27pt"
|
||||
viewBox="0.00 0.00 135.25 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>tests</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="self test implementation">
|
||||
<polygon fill="#999999" stroke="#666666" points="37.75,-19.25 0,-19.25 0,0 37.75,0 37.75,-19.25"/>
|
||||
<text text-anchor="middle" x="18.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="127.25,-19.25 73.75,-19.25 73.75,0 127.25,0 127.25,-19.25"/>
|
||||
<text text-anchor="middle" x="100.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.94,-9.62C45.14,-9.62 53.69,-9.62 62.11,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.84,-13.13 71.83,-9.63 61.83,-6.13 61.84,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
@@ -1,39 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: tests Pages: 1 -->
|
||||
<svg width="135pt" height="27pt"
|
||||
viewBox="0.00 0.00 135.25 27.25" 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 23.25)">
|
||||
<title>tests</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="self test implementation">
|
||||
<polygon fill="#999999" stroke="#666666" points="37.75,-19.25 0,-19.25 0,0 37.75,0 37.75,-19.25"/>
|
||||
<text text-anchor="middle" x="18.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="127.25,-19.25 73.75,-19.25 73.75,0 127.25,0 127.25,-19.25"/>
|
||||
<text text-anchor="middle" x="100.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.94,-9.62C45.14,-9.62 53.69,-9.62 62.11,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.84,-13.13 71.83,-9.63 61.83,-6.13 61.84,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,7 +0,0 @@
|
||||
<map id="main" name="main">
|
||||
<area shape="rect" id="Node000001" title="main function" alt="" coords="5,5,55,31"/>
|
||||
<area shape="rect" id="Node000002" href="$d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" title="self test implementation" alt="" coords="103,5,153,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="55,16,88,16,88,21,55,21"/>
|
||||
<area shape="rect" id="Node000003" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="201,5,272,31"/>
|
||||
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="153,16,185,16,185,21,153,21"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
c409a1a966c43cec22ad0eeaf0d32ac0
|
||||
@@ -1,83 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="208pt" height="27pt"
|
||||
viewBox="0.00 0.00 208.25 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="main function">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-19.25 0,-19.25 0,0 37,0 37,-19.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" target="_top" xlink:title="self test implementation">
|
||||
<polygon fill="white" stroke="#666666" points="110.75,-19.25 73,-19.25 73,0 110.75,0 110.75,-19.25"/>
|
||||
<text text-anchor="middle" x="91.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.14,-9.62C44.55,-9.62 53.37,-9.62 61.69,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.43,-13.13 71.43,-9.63 61.43,-6.13 61.43,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="200.25,-19.25 146.75,-19.25 146.75,0 200.25,0 200.25,-19.25"/>
|
||||
<text text-anchor="middle" x="173.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge2_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M110.94,-9.62C118.14,-9.62 126.69,-9.62 135.11,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.84,-13.13 144.83,-9.63 134.83,-6.13 134.84,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,57 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="208pt" height="27pt"
|
||||
viewBox="0.00 0.00 208.25 27.25" 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 23.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="main function">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-19.25 0,-19.25 0,0 37,0 37,-19.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e" target="_top" xlink:title="self test implementation">
|
||||
<polygon fill="white" stroke="#666666" points="110.75,-19.25 73,-19.25 73,0 110.75,0 110.75,-19.25"/>
|
||||
<text text-anchor="middle" x="91.88" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.14,-9.62C44.55,-9.62 53.37,-9.62 61.69,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.43,-13.13 71.43,-9.63 61.43,-6.13 61.43,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="200.25,-19.25 146.75,-19.25 146.75,0 200.25,0 200.25,-19.25"/>
|
||||
<text text-anchor="middle" x="173.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge2_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M110.94,-9.62C118.14,-9.62 126.69,-9.62 135.11,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="134.84,-13.13 144.83,-9.63 134.83,-6.13 134.84,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -1,6 +0,0 @@
|
||||
<map id="dynamic_programming::unbounded_knapsack::KnapSackFilling" name="dynamic_programming::unbounded_knapsack::KnapSackFilling">
|
||||
<area shape="rect" id="Node000001" title="Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach." alt="" coords="5,29,161,85"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000001" title=" " alt="" coords="50,29,51,19,57,10,68,5,83,3,100,5,111,12,108,16,98,10,83,8,69,10,60,14,56,21,56,29"/>
|
||||
<area shape="rect" id="Node000002" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/max.html#" title=" " alt="" coords="209,44,281,70"/>
|
||||
<area shape="poly" id="edge2_Node000001_Node000002" title=" " alt="" coords="161,54,193,54,193,60,161,60"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
8aff1469cd7bc4ca5af477bfb3eef1a3
|
||||
@@ -1,76 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: dynamic_programming::unbounded_knapsack::KnapSackFilling Pages: 1 -->
|
||||
<svg width="215pt" height="68pt"
|
||||
viewBox="0.00 0.00 214.75 67.75" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 63.75)">
|
||||
<title>dynamic_programming::unbounded_knapsack::KnapSackFilling</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.">
|
||||
<polygon fill="#999999" stroke="#666666" points="116.5,-41.75 0,-41.75 0,0 116.5,0 116.5,-41.75"/>
|
||||
<text text-anchor="start" x="8" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
|
||||
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">::unbounded_knapsack</text>
|
||||
<text text-anchor="middle" x="58.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::KnapSackFilling</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node1 -->
|
||||
<g id="edge1_Node000001_Node000001" class="edge">
|
||||
<title>Node1->Node1</title>
|
||||
<g id="a_edge1_Node000001_Node000001"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M35.85,-42.07C33.71,-51.55 41.18,-59.75 58.25,-59.75 67.85,-59.75 74.41,-57.16 77.94,-53.2"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="81.33,-54.08 80.29,-43.54 74.53,-52.43 81.33,-54.08"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="206.75,-30.5 152.5,-30.5 152.5,-11.25 206.75,-11.25 206.75,-30.5"/>
|
||||
<text text-anchor="middle" x="179.62" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::max</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge2_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge2_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M116.84,-20.88C124.98,-20.88 133.17,-20.88 140.8,-20.88"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="140.75,-24.38 150.75,-20.88 140.75,-17.38 140.75,-24.38"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,50 +0,0 @@
|
||||
<?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 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: dynamic_programming::unbounded_knapsack::KnapSackFilling Pages: 1 -->
|
||||
<svg width="215pt" height="68pt"
|
||||
viewBox="0.00 0.00 214.75 67.75" 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 63.75)">
|
||||
<title>dynamic_programming::unbounded_knapsack::KnapSackFilling</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.">
|
||||
<polygon fill="#999999" stroke="#666666" points="116.5,-41.75 0,-41.75 0,0 116.5,0 116.5,-41.75"/>
|
||||
<text text-anchor="start" x="8" y="-28.25" font-family="Helvetica,sans-Serif" font-size="10.00">dynamic_programming</text>
|
||||
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">::unbounded_knapsack</text>
|
||||
<text text-anchor="middle" x="58.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::KnapSackFilling</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node1 -->
|
||||
<g id="edge1_Node000001_Node000001" class="edge">
|
||||
<title>Node1->Node1</title>
|
||||
<g id="a_edge1_Node000001_Node000001"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M35.85,-42.07C33.71,-51.55 41.18,-59.75 58.25,-59.75 67.85,-59.75 74.41,-57.16 77.94,-53.2"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="81.33,-54.08 80.29,-43.54 74.53,-52.43 81.33,-54.08"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="206.75,-30.5 152.5,-30.5 152.5,-11.25 206.75,-11.25 206.75,-30.5"/>
|
||||
<text text-anchor="middle" x="179.62" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">std::max</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge2_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge2_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M116.84,-20.88C124.98,-20.88 133.17,-20.88 140.8,-20.88"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="140.75,-24.38 150.75,-20.88 140.75,-17.38 140.75,-24.38"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
260
d9/dec/unbounded__0__1__knapsack_8cpp_source.html
Normal file
@@ -0,0 +1,260 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!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" lang="en-US">
|
||||
<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.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: dynamic_programming/unbounded_0_1_knapsack.cpp Source File</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<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>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
<script type="text/javascript" src="../../navtree.js"></script>
|
||||
<script type="text/javascript" src="../../resize.js"></script>
|
||||
<script type="text/javascript" src="../../cookie.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/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.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 id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.12.0 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() { codefold.init(1); });
|
||||
/* @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:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('../../',true,false,'search.php','Search',true);
|
||||
$(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:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('d9/dec/unbounded__0__1__knapsack_8cpp_source.html','../../'); initResizable(true); });
|
||||
/* @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">
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle"><div class="title">unbounded_0_1_knapsack.cpp</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<a href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
|
||||
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span><span class="preprocessor">#include <cassert></span> <span class="comment">// For using assert function to validate test cases</span></div>
|
||||
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span><span class="preprocessor">#include <cstdint></span> <span class="comment">// For fixed-width integer types like std::uint16_t</span></div>
|
||||
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="preprocessor">#include <iostream></span> <span class="comment">// Standard input-output stream</span></div>
|
||||
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="preprocessor">#include <vector></span> <span class="comment">// Standard library for using dynamic arrays (vectors)</span></div>
|
||||
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> </div>
|
||||
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a> {</div>
|
||||
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> </div>
|
||||
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="keyword">namespace </span>unbounded_knapsack {</div>
|
||||
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> </div>
|
||||
<div class="foldopen" id="foldopen00058" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c"> 58</a></span>std::uint16_t <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(std::uint16_t i, std::uint16_t W,</div>
|
||||
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="keyword">const</span> std::vector<std::uint16_t>& val,</div>
|
||||
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keyword">const</span> std::vector<std::uint16_t>& wt,</div>
|
||||
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> std::vector<std::vector<int>>& <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>) {</div>
|
||||
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="keywordflow">if</span> (i == 0) {</div>
|
||||
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="keywordflow">if</span> (wt[0] <= W) {</div>
|
||||
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="keywordflow">return</span> (W / wt[0]) *</div>
|
||||
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> val[0]; <span class="comment">// Take as many of the first item as possible</span></div>
|
||||
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="keywordflow">return</span> 0; <span class="comment">// Can't take the first item</span></div>
|
||||
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> }</div>
|
||||
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> }</div>
|
||||
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="keywordflow">if</span> (<a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] != -1)</div>
|
||||
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W]; <span class="comment">// Return result if available</span></div>
|
||||
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> </div>
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="keywordtype">int</span> nottake =</div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(i - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value without taking item i</span></div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordtype">int</span> take = 0;</div>
|
||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <span class="keywordflow">if</span> (W >= wt[i]) {</div>
|
||||
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> take = val[i] + <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(i, W - wt[i], val, wt,</div>
|
||||
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value taking item i</span></div>
|
||||
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> }</div>
|
||||
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] =</div>
|
||||
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> std::max(take, nottake); <span class="comment">// Store and return the maximum value</span></div>
|
||||
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> </div>
|
||||
<div class="foldopen" id="foldopen00093" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"><a class="line" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a1bcff7f76de48fa7f629480f8f18b5ef"> 93</a></span>std::uint16_t <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(std::uint16_t N, std::uint16_t W,</div>
|
||||
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="keyword">const</span> std::vector<std::uint16_t>& val,</div>
|
||||
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="keyword">const</span> std::vector<std::uint16_t>& wt) {</div>
|
||||
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">if</span> (N == 0)</div>
|
||||
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="keywordflow">return</span> 0; <span class="comment">// Expect 0 since no items</span></div>
|
||||
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> std::vector<std::vector<int>> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
|
||||
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> N, std::vector<int>(W + 1, -1)); <span class="comment">// Initialize memoization table</span></div>
|
||||
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(N - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Start the calculation</span></div>
|
||||
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> </div>
|
||||
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span>} <span class="comment">// namespace unbounded_knapsack</span></div>
|
||||
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> </div>
|
||||
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span>} <span class="comment">// namespace dynamic_programming</span></div>
|
||||
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> </div>
|
||||
<div class="foldopen" id="foldopen00111" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"><a class="line" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e"> 111</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>() {</div>
|
||||
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="comment">// Test Case 1</span></div>
|
||||
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> std::uint16_t N1 = 4; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> std::vector<std::uint16_t> wt1 = {1, 3, 4, 5}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> std::vector<std::uint16_t> val1 = {6, 1, 7, 7}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> std::uint16_t W1 = 8; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <span class="comment">// Test the function and assert the expected output</span></div>
|
||||
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> N1, W1, val1, wt1) == 48);</div>
|
||||
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> std::cout << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> << dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> N1, W1, val1, wt1)</div>
|
||||
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> </div>
|
||||
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="comment">// Test Case 2</span></div>
|
||||
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> std::uint16_t N2 = 3; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> std::vector<std::uint16_t> wt2 = {10, 20, 30}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> std::vector<std::uint16_t> val2 = {60, 100, 120}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> std::uint16_t W2 = 5; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> <span class="comment">// Test the function and assert the expected output</span></div>
|
||||
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> N2, W2, val2, wt2) == 0);</div>
|
||||
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> std::cout << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> << dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> N2, W2, val2, wt2)</div>
|
||||
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> </div>
|
||||
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> <span class="comment">// Test Case 3</span></div>
|
||||
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> std::uint16_t N3 = 3; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> std::vector<std::uint16_t> wt3 = {2, 4, 6}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> std::vector<std::uint16_t> val3 = {5, 11, 13}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> std::uint16_t W3 = 27; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> <span class="comment">// Test the function and assert the expected output</span></div>
|
||||
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> N3, W3, val3, wt3) == 27);</div>
|
||||
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> std::cout << <span class="stringliteral">"Maximum Knapsack value "</span></div>
|
||||
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> << dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> N3, W3, val3, wt3)</div>
|
||||
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> </div>
|
||||
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="comment">// Test Case 4</span></div>
|
||||
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> std::uint16_t N4 = 0; <span class="comment">// Number of items</span></div>
|
||||
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> std::vector<std::uint16_t> wt4 = {}; <span class="comment">// Weights of the items</span></div>
|
||||
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> std::vector<std::uint16_t> val4 = {}; <span class="comment">// Values of the items</span></div>
|
||||
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> std::uint16_t W4 = 10; <span class="comment">// Maximum capacity of the knapsack</span></div>
|
||||
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> N4, W4, val4, wt4) == 0);</div>
|
||||
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> std::cout << <span class="stringliteral">"Maximum Knapsack value for empty arrays: "</span></div>
|
||||
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> << dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
|
||||
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> N4, W4, val4, wt4)</div>
|
||||
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> </div>
|
||||
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> std::cout << <span class="stringliteral">"All test cases passed!"</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> </div>
|
||||
<div class="foldopen" id="foldopen00170" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"><a class="line" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 170</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||||
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> <a class="code hl_function" href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// Run self test implementation</span></div>
|
||||
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span>}</div>
|
||||
</div>
|
||||
<div class="ttc" id="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> <a href="../../de/d8c/partition__problem_8cpp_source.html#l00039">partition_problem.cpp:39</a></div></div>
|
||||
<div class="ttc" id="anamespacedynamic__programming_html"><div class="ttname"><a href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></div><div class="ttdoc">Dynamic Programming algorithms.</div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a1bcff7f76de48fa7f629480f8f18b5ef"><div class="ttname"><a href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a></div><div class="ttdeci">std::uint16_t unboundedKnapsack(std::uint16_t N, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt)</div><div class="ttdoc">Wrapper function to initiate the unbounded knapsack calculation.</div><div class="ttdef"><b>Definition</b> <a href="#l00093">unbounded_0_1_knapsack.cpp:93</a></div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">self test implementation</div><div class="ttdef"><b>Definition</b> <a href="#l00111">unbounded_0_1_knapsack.cpp:111</a></div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">main function</div><div class="ttdef"><b>Definition</b> <a href="#l00170">unbounded_0_1_knapsack.cpp:170</a></div></div>
|
||||
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_afe447a5979582174908695952c8a079c"><div class="ttname"><a href="../../d9/dec/unbounded__0__1__knapsack_8cpp.html#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a></div><div class="ttdeci">std::uint16_t KnapSackFilling(std::uint16_t i, std::uint16_t W, const std::vector< std::uint16_t > &val, const std::vector< std::uint16_t > &wt, std::vector< std::vector< int > > &dp)</div><div class="ttdoc">Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.</div><div class="ttdef"><b>Definition</b> <a href="#l00058">unbounded_0_1_knapsack.cpp:58</a></div></div>
|
||||
</div><!-- fragment --></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- 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="../../d9/dec/unbounded__0__1__knapsack_8cpp.html">unbounded_0_1_knapsack.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.12.0 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||