Skip to content

Commit 5c78361

Browse files
committed
Modified Dosctrings
1 parent bb8a0f6 commit 5c78361

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pygorithm/dynamic_programming/binary_knapsack.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
Created At: 25th August 2017
44
"""
55
import inspect
6-
# TODO: Explain how this works / Explain what a knapsack is
76

87

98
def knapsack(w, value, weight):
109
"""
10+
The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of
11+
items, each with a weight and a value, determine the number of each item to include in a collection
12+
so that the total weight is less than or equal to a given limit and the total value is as large as
13+
possible. It derives its name from the problem faced by someone who is constrained by a fixed-size
14+
knapsack and must fill it with the most valuable items.
15+
1116
:param w: maximum weight capacity
1217
:param value: an array of values of items in the knapsack
1318
:param weight: an array of weights of items in the knapsack

pygorithm/dynamic_programming/lis.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ def longest_increasing_subsequence(_list):
88
"""
99
The Longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence of a
1010
given sequence such that all elements of the subsequence are sorted in increasing order. For example,
11-
the length of LIS for {10, 22, 9, 33, 21, 50, 41, 60, 80} is 6 and LIS is {10, 22, 33, 50, 60, 80}.
12-
:param _list:
13-
:return:
11+
the length of LIS for [10, 22, 9, 33, 21, 50, 41, 60, 80] is 6 and LIS is [10, 22, 33, 50, 60, 80].
12+
13+
:param _list: an array of elements
14+
:return: returns a tuple of maximum length of lis and an array of the elements of lis
1415
"""
1516
# Initialize list with some value
1617
lis = [1] * len(_list)

0 commit comments

Comments
 (0)