Presentation is loading. Please wait.

Presentation is loading. Please wait.

Robbing a House with Greedy Algorithms

Similar presentations


Presentation on theme: "Robbing a House with Greedy Algorithms"— Presentation transcript:

1 Robbing a House with Greedy Algorithms
Casey O’Brien

2 Knapsack Problem

3

4 Your Knapsack Max Weight: 10 pounds

5 Item

6 Item Value 13 5 3 6 9

7 Item Value Weight 13 8 5 3 0.6 6 1.5 9

8 Goal: Maximize total value
Constraint: Total weight cannot exceed 10 pounds

9 Item Value Weight 13 8 5 3 0.6 6 1.5 9

10 Item Value Weight Value/Weight 13 8 1.6 5 1 3 0.6 6 1.5 4 9

11 Play The Robber!

12 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

13 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

14 Item Value Weight Value/Weight Knapsack 12 8 1.6 5 1 3 0.6 6 1.5 4 9

15 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

16 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

17 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

18 Final Knapsack: Final Value: $14

19 Play The Robber!

20 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

21 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

22 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

23 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

24 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

25 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

26 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

27 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

28 Final Knapsack: Final Value: $19

29 Final Knapsack: Final Value: $16

30 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

31 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

32 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

33 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

34 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

35 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

36 Final Knapsack: Final Value: $14

37 Final Knapsack: Final Value: $20

38 Final Knapsack: Final Value: $17

39 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

40 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

41 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

42 Final Knapsack: Final Value: $15

43 Final Knapsack: Final Value: $18

44 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

45 Greedy Algorithms

46 Greedy by Largest Value

47 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

48 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

49 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

50 Final Knapsack: Final Value: $19

51 Greedy by Smallest Weight

52 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

53 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

54 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

55 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

56 Final Knapsack: Final Value: $18

57 Greedy by Largest Ratio

58 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

59 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

60 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

61 Item Value Weight Value/Weight Knapsack 13 8 1.6 5 1 3 0.6 6 1.5 4 9

62 Final Knapsack: Final Value: $18

63 Greedy Algorithms do not guarantee optimal solution
Problem: Greedy Algorithms do not guarantee optimal solution

64 Exhaustive Enumeration

65 Exhaustive Enumeration
Try All Possibilities

66 How Many Possibilities?

67

68

69

70

71

72

73

74

75 Final Knapsack: Final Value: $20

76 Problem: Takes Too Long!

77 40 Items

78 ~1 Trillion Possibilities
40 Items ~1 Trillion Possibilities

79 ~1 Trillion Possibilities
40 Items ~1 Trillion Possibilities ~35,000 Years to Compute

80 What Can We Do?

81 Settle For Less Than Optimal

82 Recall Greedy Algorithms:
By Value: $19 By Weight: $18 By Ratio: $18 Optimal: $20

83 Moral of the Story: We can use Greedy Algorithms to approximate solutions to the knapsack problem quickly.


Download ppt "Robbing a House with Greedy Algorithms"

Similar presentations


Ads by Google