-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathknapsack.html
More file actions
42 lines (36 loc) · 1.67 KB
/
Copy pathknapsack.html
File metadata and controls
42 lines (36 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
<head>
<title>Knapsack Problem</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="knapsack.js"></script>
<link rel="stylesheet" type="text/css" href="knapsack.css">
</head>
<body style="width: 800px">
<h2 style="text-align:center; margin-top:10px">The Burglar's Dilema</h2>
<p><center>
<img src="house.png" width="400"><img src="burglar.png" width="200">
</center>
<p>Being a burglar isn't easy! Our friend above has just entered a
house and is trying to decide what to take. Unfortunately his
knapsack only holds <b>20kg</b>. What strategy should he use in picking
objects so as to maximize the value of his haul?
<p>Let's try out three possible strategies. Considering the items
remaining in the house that will still fit in the knapsack, the
burglar selects the item based on
<ol>
<li>"Max Value" -- choose the item with the greatest value</li>
<li>"Min Weight" -- choose the time with the least weight</li>
<li>"Max Value/Weight" -- choose the item with the largest value-to-weight ratio</li>
</ol>
<p>Try out each strategy using the simulation below and record the
total value of all the items in the knapsack.
<div class="knapsack" data-maxweight="20">
<img src="clock.png" data-value="175" data-weight="10" data-name="clock">
<img src="painting.png" data-value="90" data-weight="9" data-name="painting">
<img src="radio.png" data-value="20" data-weight="4" data-name="radio">
<img src="vase.png" data-value="50" data-weight="2" data-name="vase">
<img src="book.png" data-value="10" data-weight="1" data-name="book">
<img src="computer.png" data-value="200" data-weight="20" data-name="computer">
</div>
</body>
</html>