Lecture notes · Thinking with Data · Lecture 1

Introduction and Optimization Problems

MIT 6.0002 Intro to Computational Thinking and Data Science, lecture 1, explained in plain English

Want this lecture to stick? In LessonBound you get checked practice questions for every part, can ask about anything you don't get, and can listen with your screen off. Free, no ads.

Learn this lecture free

Watch or read the original lecture: MIT OpenCourseWare.

Part 1 · 0:00–10:00

This part introduces computational models and explains optimization problems, using a travel example and the knapsack problem.

Key ideas

Words to know

objective function
The goal you are trying to reach, such as making something as large or as small as possible.
constraints
Rules or limits you have to follow, which rule out some choices.
knapsack problem
A puzzle where you pick items to carry in a bag that can only hold so much, aiming for the most value.
0/1 knapsack problem
The knapsack puzzle where each item must be taken whole or left behind completely.

Example

Imagine you want to get from New York to Boston as fast as possible, but you only have $100. The goal of fastest travel is the objective function, and the $100 limit is a constraint. The $100 limit rules out the plane, so you are left with other choices.

3 checked practice questions for this part are in the app.

Part 2 · 10:00–20:00

This part explains why a simple greedy method works for the easy version of the knapsack problem, why it can fail for the all-or-nothing version, and why trying every option is too slow for large problems.

Key ideas

Words to know

greedy algorithm
A method that always picks the best option available at each step, without looking ahead.
brute force
Trying every possible answer one by one and keeping the best one that works.
power set
The full list of every possible group you can make from a set of items, including the empty group and the group with everything.
exponential
Growing very fast, so each extra item roughly doubles the work needed. Exponential problems get out of hand quickly.

Example

Imagine packing a suitcase with a limit. If you can cut a bag of sugar into any amount, you can fill the suitcase neatly with the best stuff first. But if every item is a whole box, picking the biggest box first might stop you from fitting two smaller boxes that together are worth more.

3 checked practice questions for this part are in the app.

Part 3 · 20:00–30:00

This part shows how a simple greedy method picks a meal within a calorie budget, and how fast that method runs.

Key ideas

Words to know

greedy algorithm
A method that makes the best-looking choice at each step and never goes back to change it.
knapsack problem
A puzzle where you must pick items to fit into a limited space or budget, getting the most value without going over.
side effect
A change a function makes to something outside itself, such as altering a list that was passed in. Good code tries to avoid this.
order n log n
A way of describing how the number of steps grows as the input grows. Here it means the work grows a bit faster than the list size, but still stays manageable.

Example

Imagine packing a suitcase with a weight limit. You sort your items from most useful to least useful, then add each one that still fits. If a big item is too heavy, you skip it and check the smaller ones after it. That is the same idea as the greedy method in this lesson.

3 checked practice questions for this part are in the app.

Part 4 · 30:00–40:48

This part shows how a greedy algorithm picks the best-looking choice at each step, why that can miss the best overall answer, and how the lambda shortcut builds a small function inline.

Key ideas

Words to know

lambda
A short way to write a small function in one line, without giving it a name.
anonymous function
A function that has no name. You define it where you use it, like a quick one-off tool.
greedy algorithm
A method that always takes the option that looks best right now, without planning ahead.
local maximum
A high point that is higher than everything right next to it, but not the highest point overall.

Example

Imagine climbing a hilly area in fog and always stepping uphill whenever you can. You might reach the top of a small hill and stop, even though a much taller mountain is nearby. The lesson uses this to show why a greedy choice at each step can miss the best overall result.

3 checked practice questions for this part are in the app.

Notes written by AI (Claude) from the lecture's official transcript, so check anything important against the lecture. MIT OpenCourseWare · CC BY-NC-SA 4.0 · not affiliated with or endorsed by MIT. These notes are shared under the same license.

LessonBound · Free lecture notes · Privacy · Terms · New York