Skip to content

Commit f2d1e18

Browse files
authoredOct 25, 2018
Update README.md
1 parent 575712e commit f2d1e18

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎Branch and Bound/0_1 Knapsack/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# 0/1 Knapsack Problem (using BRANCH & BOUND)
22

3-
#Problem:
3+
## Problem:
44

55
1. Given two integer arrays val[0..n-1] and wt[0..n-1] that represent values and weights associated with n items respectively.
66
2. Find out the maximum value subset of val[] such that sum of the weights of this subset is smaller than or equal to Knapsack capacity W.
77
3. We have ‘n’ items with value v1 , v2 . . . vn and weight of the corresponding items is w1 , w2 . . . Wn . Max capacity is W .
88
4. We can either choose or not choose an item. We have x1 , x2 . . . xn. Here xi = { 1 , 0 }. xi = 1 , item chosen xi = 0 , item not chosen.
99

10-
##Why Branch And Bound?
10+
## Why Branch And Bound?
1111
- Greedy approach works only for fractional knapsack problem.
1212
- If weights are not integers , dynamic programming will not work.
1313
- There are 2n possible combinations of item , complexity for brute force goes exponentially.
1414

15-
##Algorithm:
15+
## Algorithm:
1616
1. Sort all items in decreasing order of ratio of value per unit weight so that an upper bound can be computed using Greedy Approach.
1717
2. Initialize maximum profit, maxProfit = 0
1818
3. Create an empty queue, Q.

0 commit comments

Comments
 (0)
Please sign in to comment.