mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
Optimize and Format Knapsack Memoization Algorithm (#5685)
This commit is contained in:
@ -31,4 +31,19 @@ public class KnapsackMemoizationTest {
|
||||
int capacity = 50;
|
||||
assertEquals(220, knapsackMemoization.knapSack(capacity, weight, value, weight.length));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test4() {
|
||||
int[] weight = {1, 2, 3};
|
||||
int[] value = {10, 20, 30};
|
||||
int capacity = 0;
|
||||
assertEquals(0, knapsackMemoization.knapSack(capacity, weight, value, weight.length));
|
||||
}
|
||||
@Test
|
||||
void test5() {
|
||||
int[] weight = {1, 2, 3, 8};
|
||||
int[] value = {10, 20, 30, 40};
|
||||
int capacity = 50;
|
||||
assertEquals(100, knapsackMemoization.knapSack(capacity, weight, value, weight.length));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user