File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
pygorithm/greedy_algorithm Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 33Created On: 26th August 2017
44"""
55import inspect
6- # TODO: Explain what this is / how it works
76
87
98def activity_selection (start_times , finish_times ):
109 """
10+ The activity selection problem is a combinatorial optimization problem concerning the selection of
11+ non-conflicting activities to perform within a given time frame, given a set of activities each marked
12+ by a start time (si) and finish time (fi). The problem is to select the maximum number of activities
13+ that can be performed by a single person or machine, assuming that a person can only work on a single
14+ activity at a time.
15+
1116 :param start_times: An array that contains start time of all activities
1217 :param finish_times: An array that conatins finish time of all activities
1318 """
Original file line number Diff line number Diff line change 33Created On: 22nd August 2017
44"""
55import inspect
6- # TODO: Explain how this works / Explain what a knapsack is
76
87
98def knapsack (w , item_values , item_weights ):
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 so
12+ 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 item_values: a list of values of items in the knapsack
1318 :param item_weights: a list of weights of items in the knapsack
You can’t perform that action at this time.
0 commit comments