From 179526ce7a939ef4a9f2498d2cd779ec39b371e6 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 18 Oct 2022 21:13:38 +0000 Subject: [PATCH] Documentation for ee9835378f925056c67beae7d479c2b39ac217e8 --- db/d16/0__1__knapsack_8cpp.html | 30 +++++++++---------- ...5edf30f336885e5b851f6b7199c6cd1_cgraph.map | 2 +- ...5edf30f336885e5b851f6b7199c6cd1_cgraph.md5 | 2 +- ...5edf30f336885e5b851f6b7199c6cd1_cgraph.svg | 2 +- ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 2 +- ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 2 +- ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 2 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map | 2 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 | 2 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg | 2 +- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/db/d16/0__1__knapsack_8cpp.html b/db/d16/0__1__knapsack_8cpp.html index 33ace1077..bfefccf6a 100644 --- a/db/d16/0__1__knapsack_8cpp.html +++ b/db/d16/0__1__knapsack_8cpp.html @@ -130,10 +130,10 @@ Namespaces Functions template<size_t n> int dynamic_programming::knapsack::maxKnapsackValue (const int capacity, const std::array< int, n > &weight, const std::array< int, n > &value) - Picking up all those items whose combined weight is below given capacity and calculating value of those picked items.Trying all possible combinations will yield the maximum knapsack value. More...
+ Picking up all those items whose combined weight is below the given capacity and calculating the value of those picked items. Trying all possible combinations will yield the maximum knapsack value. More...
  static void test () - Function to test above algorithm. More...
+ Function to test the above algorithm. More...
  int main ()  Main function. More...
@@ -172,7 +172,7 @@ Algorithm
128 test();
129 return 0;
130}
-
test
static void test()
Function to test above algorithm.
Definition: 0_1_knapsack.cpp:96
+
test
static void test()
Function to test the above algorithm.
Definition: 0_1_knapsack.cpp:96
Here is the call graph for this function:
@@ -216,7 +216,7 @@ template<size_t n>
-

Picking up all those items whose combined weight is below given capacity and calculating value of those picked items.Trying all possible combinations will yield the maximum knapsack value.

+

Picking up all those items whose combined weight is below the given capacity and calculating the value of those picked items. Trying all possible combinations will yield the maximum knapsack value.

Template Parameters
@@ -226,17 +226,17 @@ template<size_t n>
Parameters
nsize of the weight and value array
- - + +
capacitycapacity of the carrying bag
weightarray representing weight of items
valuearray representing value of items
weightarray representing the weight of items
valuearray representing the value of items
-
Returns
maximum value obtainable with given capacity.
+
Returns
maximum value obtainable with a given capacity.
52 {
53 std::vector<std::vector<int> > maxValue(n + 1,
54 std::vector<int>(capacity + 1, 0));
55 // outer loop will select no of items allowed
-
56 // inner loop will select capcity of knapsack bag
+
56 // inner loop will select the capacity of the knapsack bag
57 int items = sizeof(weight) / sizeof(weight[0]);
58 for (size_t i = 0; i < items + 1; ++i) {
59 for (size_t j = 0; j < capacity + 1; ++j) {
@@ -245,22 +245,22 @@ template<size_t n>
62 // will be zero
63 maxValue[i][j] = 0;
64 } else if (weight[i - 1] <= j) {
-
65 // if the ith item's weight(in actual array it will be at i-1)
+
65 // if the ith item's weight(in the actual array it will be at i-1)
66 // is less than or equal to the allowed weight i.e. j then we
67 // can pick that item for our knapsack. maxValue will be the
68 // obtained either by picking the current item or by not picking
69 // current item
70
-
71 // picking current item
+
71 // picking the current item
72 int profit1 = value[i - 1] + maxValue[i - 1][j - weight[i - 1]];
73
-
74 // not picking current item
+
74 // not picking the current item
75 int profit2 = maxValue[i - 1][j];
76
77 maxValue[i][j] = std::max(profit1, profit2);
78 } else {
-
79 // as weight of current item is greater than allowed weight, so
-
80 // maxProfit will be profit obtained by excluding current item.
+
79 // as the weight of the current item is greater than the allowed weight, so
+
80 // maxProfit will be profit obtained by excluding the current item.
81 maxValue[i][j] = maxValue[i - 1][j];
82 }
83 }
@@ -303,7 +303,7 @@ Here is the call graph for this function:
-

Function to test above algorithm.

+

Function to test the above algorithm.

Returns
void
96 {
97 // Test 1
@@ -330,7 +330,7 @@ Here is the call graph for this function:
118 std::cout << "Maximum Knapsack value with " << n2 << " items is "
119 << max_value2 << std::endl;
120}
-
int maxKnapsackValue(const int capacity, const std::array< int, n > &weight, const std::array< int, n > &value)
Picking up all those items whose combined weight is below given capacity and calculating value of tho...
Definition: 0_1_knapsack.cpp:51
+
int maxKnapsackValue(const int capacity, const std::array< int, n > &weight, const std::array< int, n > &value)
Picking up all those items whose combined weight is below the given capacity and calculating the valu...
Definition: 0_1_knapsack.cpp:51
T endl(T... args)
diff --git a/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.map b/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.map index 3daefe4dc..3ca42ae82 100644 --- a/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.map +++ b/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.map @@ -1,4 +1,4 @@ - + diff --git a/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.md5 b/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.md5 index bf85858c1..b200ebd52 100644 --- a/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.md5 +++ b/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.md5 @@ -1 +1 @@ -724ed1407e50869dde170dd42b6d573e \ No newline at end of file +f139929d34c31e39ac08d10326fb2779 \ No newline at end of file diff --git a/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.svg b/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.svg index 5adf8e217..4bedc40df 100644 --- a/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.svg +++ b/db/d16/0__1__knapsack_8cpp_a15edf30f336885e5b851f6b7199c6cd1_cgraph.svg @@ -11,7 +11,7 @@ Node1 - + dynamic_programming ::knapsack::maxKnapsackValue diff --git a/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map index b657ba0ac..fc4761e30 100644 --- a/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map +++ b/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -1,4 +1,4 @@ - + diff --git a/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 index 216cba83e..f17df9695 100644 --- a/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 +++ b/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -1 +1 @@ -46b6febb5b5840bc7a05d9ec95c6ba32 \ No newline at end of file +5f681fb811530ee5c7eb42a5d7253788 \ No newline at end of file diff --git a/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg index 850835ba8..ac27c03f7 100644 --- a/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg +++ b/db/d16/0__1__knapsack_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -11,7 +11,7 @@ Node1 - + test diff --git a/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map index e69a18409..2fd364306 100644 --- a/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map +++ b/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -1,5 +1,5 @@ - + diff --git a/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 index 15e1f5f7f..76d31843c 100644 --- a/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 +++ b/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -1 +1 @@ -ce0c49ee8db22c9cca13a98a2d46cfb0 \ No newline at end of file +949bae17c94477d71c596af699efcd98 \ No newline at end of file diff --git a/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg index 8ee0e6296..9fb5ceac7 100644 --- a/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg +++ b/db/d16/0__1__knapsack_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -20,7 +20,7 @@ Node2 - + test