Skip to content

Commit 9528c71

Browse files
authored
Added testcases for Zero One Knapsack (TheAlgorithms#1109)
1 parent 7a1141b commit 9528c71

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { zeroOneKnapsack } from '../ZeroOneKnapsack'
2+
3+
describe('ZeroOneKnapsack', () => {
4+
it('zeroOneKnapsack when capacity is 4 and 5 items', () => {
5+
expect(zeroOneKnapsack([[1, 8], [2, 4], [3, 0], [2, 5], [2, 3]], 5, 4, [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]])).toBe(13)
6+
})
7+
8+
it('zeroOneKnapsack when capacity is 1 and 1 items', () => {
9+
expect(zeroOneKnapsack([[1, 80]], 1, 1, [[-1, -1], [-1, -1]])).toBe(80)
10+
})
11+
12+
it('zeroOneKnapsack when capacity is 0 and 1 items', () => {
13+
expect(zeroOneKnapsack([[1, 80]], 1, 0, [[-1], [-1]])).toBe(0)
14+
})
15+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy