MITx 6.00.2x - Introduction To Computational Thinking and Data Science
MITx 6.00.2x - Introduction To Computational Thinking and Data Science
Lecture 1, Segment 1
John Guttag
MIT Department of Electrical Engineering and
Computer Science
6.00.1X LECTURE 1
Computational Models
Using computation to help understand the world in
which we live
Experimental devices that help us to understand
something that has happened or to predict the future
Optimization models
Statistical models
Simulation models
6.00.2X LECTURE 2
What Is an Optimization Model?
6.00.1X LECTURE 3
Takeaways
6.00.1X LECTURE 4
Knapsack and Bin-packing Problems
CC BY Mike Mozart
CC BY JOADL
CC BY Tm
6.00.1X LECTURE 5
Knapsack Problem
versus
6.00.1X LECTURE 6
My Least-favorite Knapsack Problem
1500
Calorie
Capacity
CC BY maebmjj
CC BY JOADL
CC BY Zantastik~commonswiki CC BY Gorivero
6.00.2X LECTURE 7
0/1 Knapsack Problem, Formalized
Each item is represented by a pair, <value, weight>
The knapsack can accommodate items with a total
weight of no more than w
A vector, L, of length n, represents the set of
available items. Each element of the vector is an
item
A vector, V, of length n, is used to indicate whether
or not items are taken. If V[i] = 1, item I[i] is taken.
If V[i] = 0, item I[i] is not taken
6.00.2X LECTURE 8
0/1 Knapsack Problem, Formalized
6.00.2X LECTURE 9
Brute Force Algorithm
1. Enumerate all possible combinations of items. That
is to say, generate all subsets of the set of subjects.
This is called the power set.
2. Remove all of the combinations whose total units
exceeds the allowed weight.
3. From the remaining combinations choose any one
whose value is the largest.
6.00.2X LECTURE 10
Often Not Practical
How big is power set?
Recall
◦ A vector, V, of length n, is used to indicate whether or not
items are taken. If V[i] = 1, item I[i] is taken. If V[i] = 0, item I[i]
is not taken
How many possible different values can V have?
◦ As many different binary numbers as can be represented
in n bits
6.00.2X LECTURE 11
Are We Just Being Stupid?
Alas, no
0/1 knapsack problem is inherently exponential
But don’t despair
CC BY Monumenteer2014
6.00.2X LECTURE 12