CS50 Week 0 Explained: Binary, Algorithms and Scratch
Week 0 is the lecture that hooks people. Before any code, it answers a question most of us have never asked: how does a machine that only understands on and off end up showing you photos, emoji and text? Then it introduces the idea the whole course is built on, the algorithm, and has you build something in Scratch, a visual programming language made of drag-and-drop blocks.

Jump to the key moments
- 2:24Artificial intelligence
- 16:06Binary
- 29:46ASCII
- 40:52Unicode
- 44:57Colour
- 55:23Algorithms
- 1:04:45Pseudocode
- 1:14:09Scratch
- 1:33:51Abstraction
- 1:51:59Ivy's Hardest Game
The big idea: everything is numbers, and numbers are bits
A computer is built from billions of tiny switches that are either off or on, 0 or 1. One of those values is a bit. With a single bit you can count to 1. With more bits, each position is worth twice the one to its right (1, 2, 4, 8, 16 and so on), so eight bits can represent any number from 0 to 255. That's binary, and eight bits make a byte.
Once you have numbers, you can represent anything by agreeing on what the numbers mean:
- Text: ASCII agreed that 65 means "A", 66 means "B", and so on. It only has room for about 128 characters, so Unicode extended the idea to cover every writing system, Sinhala and Tamil included, plus emoji.
- Colour: a pixel is three numbers, one each for red, green and blue (RGB), each from 0 to 255.
- Images, video and sound: lots of pixels, lots of frames, lots of samples. It's numbers all the way down.
The same bits can mean different things depending on context. The same three bytes could be a colour or three letters. Programs keep track of which is which.
Algorithms: step-by-step instructions
An algorithm is a precise set of steps for solving a problem. The lecture's famous example is finding a name in a phone book. You could turn one page at a time (correct, but slow), two pages at a time (faster, but you might skip the name), or open the book in the middle, decide which half the name is in, and throw the other half away. The last approach needs only about 10 steps for a 1,000-page book and 11 for a 2,000-page one. Doubling the problem adds just one step. Hold on to that idea: Week 3 formalises it.
Pseudocode is how you write an algorithm down before you code it: short, numbered lines in plain English, using a few building blocks that show up in every programming language:
- Functions: actions ("open the book").
- Conditionals: decisions ("if the person is on this page").
- Boolean expressions: the yes/no questions those decisions ask.
- Loops: repetition ("go back to step 3").
Scratch: the same ideas with blocks
Scratch lets you write programs by snapping blocks together, so you can focus on logic without worrying about syntax. Every building block above has a Scratch version: "when green flag clicked" to start, "if/else" for conditionals, "forever" and "repeat" for loops, and variables for storing things like a score. The lecture also introduces abstraction: when a group of blocks does one recognisable thing ("meow"), you wrap it in a custom block with a clear name, so the rest of your program reads like a story.
Problem Set 0: what it asks
Starting from Scratch is entirely open: a game, an animation or a story, built at scratch.mit.edu. It has to meet a short list of requirements (at least two sprites, a few scripts, a conditional, a loop, a variable, and a custom block that takes an input), and it should be more ambitious than the small examples in the lecture. Before you start, you also set up the course on Harvard's side with a GitHub account. The problem set page walks you through it.
Where people get stuck
- Starting too big. Pick an idea you could explain in one sentence. Build the smallest version that works, save it, then add to it.
- The custom block with an input. This is the requirement people miss. Find something you do more than once with a different value each time, like moving a sprite by different amounts, and turn it into a block that takes that value as an input.
- Losing work. Save often with File, then Save now.
Check yourself
How many different values can 3 bits represent?
Eight (0 to 7). Each extra bit doubles the count: 2 × 2 × 2.
Why was Unicode needed when ASCII already existed?
ASCII only has room for about 128 characters, which is enough for English but not for most of the world's languages or for emoji. Unicode uses more bits per character, so it has room for all of them.
The phone book has 1,024 pages. Roughly how many steps does "split in half" need in the worst case?
About 10, because 210 = 1,024. Page by page could take all 1,024.
What's the point of a custom block in Scratch?
It's abstraction: you give a group of steps a name so you can reuse it and forget how it works inside. Every language you meet later has the same idea, called a function.
Teaching Scratch to a younger learner? Cocoon Kids starts with Scratch too.
See Cocoon Kids →