Skip to content
Book a Call → mycocoon.life
← Back to Blog Students 9 min read

CS50's AI Lecture Explained: From Decision Trees to Large Language Models

Between SQL and web development, CS50x 2026 includes a shorter lecture, under 50 minutes, on artificial intelligence. It has no problem set, and it's still one of the most useful hours in the course: it traces a line from hand-written rules to the large language models behind today's chatbots, and shows why they sometimes confidently make things up.

🎓
An unofficial study guide. CS50 is Harvard University's Introduction to Computer Science, taught by David J. Malan. The lectures, notes and problem sets linked here belong to Harvard and are shared under CC BY-NC-SA 4.0. This guide is Cocoon's own writing and is not affiliated with or endorsed by Harvard. Take the course itself, free, at cs50.harvard.edu/x. Part of our CS50 study series. Keep track of your progress with our free CS50 Study Tracker.
CS50's AI Lecture Explained: From Decision Trees to Large Language Models, pixel-art illustration
CS50's AI Lecture Explained: From Decision Trees to Large Language Models
Thumbnail of CS50x 2026: Artificial Intelligence
Watch the lecture

CS50x 2026: Artificial Intelligence

48 min · Harvard University · CS50 on YouTube

Jump to the key moments

  1. 2:53Generative AI
  2. 7:56Prompt engineering
  3. 9:30CS50.ai
  4. 11:05Copilot
  5. 20:52Decision trees
  6. 23:56Minimax
  7. 29:00Machine learning
  8. 37:26Deep learning
  9. 42:55Large language models
  10. 46:04Hallucinations

Generative AI and prompts

The lecture opens with generative AI, systems that produce new text, images or code. Prompt engineering is the craft of instructing them well. A system prompt sets the rules and persona in the background, and the user prompt is what you type. CS50's own duck at cs50.ai is an example: its system prompt tells it to guide students towards answers rather than hand them over. That's also why it's the only AI tool the course allows.

Before machine learning: rules and search

Early AI meant writing the rules yourself. A decision tree is a flowchart of questions ("is the ball to the left of the paddle?") leading to actions, which works for simple games like Breakout. For games with an opponent, minimax imagines every possible future move: you try to maximise your score while assuming the opponent minimises it. That's perfect for tic-tac-toe, and impossible for chess or Go, where the number of possible games is astronomically large. That limit is why AI had to start learning instead of searching.

Machine learning

In machine learning, the program learns from data or experience instead of following rules you wrote. The lecture covers reinforcement learning: reward good outcomes, penalise bad ones, and let the system work out a strategy through trial and error. It also covers the balance between exploring new options and exploiting what already works. Unsupervised learning, by contrast, finds patterns in data nobody has labelled.

Deep learning and neural networks

A neural network passes numbers through layers of simple units. Each connection has a weight, and training nudges the weights until the outputs match the examples. Stack many layers and you have deep learning, which is good at spotting patterns in images, sound and text that no human could write rules for.

Large language models

An LLM is a very large neural network trained on huge amounts of text to predict what comes next. The key architecture, the transformer, uses attention to work out which earlier words matter most to each new one. That's how it keeps track of meaning across a long passage. The result is fluent, and often useful.

Hallucinations

Because an LLM generates what's likely, not what's verified, it can produce confident, plausible and wrong answers, known as hallucinations. The practical lesson for everyone, programmers or not, is to treat AI output as a draft to check, never as a source of truth.

How this connects to the rest of CS50

Everything in this lecture is built from the course so far: numbers representing data (Week 0), algorithms and their running time (Week 3), and data structures (Week 5). If you want to go deeper, Harvard's follow-on course CS50AI covers search, machine learning and neural networks in Python.

Check yourself

Why can't minimax play chess by trying every possible game?

There are far too many possible games to explore in any reasonable time, so real chess engines limit how far ahead they look and estimate the rest.

What's the difference between a system prompt and a user prompt?

The system prompt sets the rules and behaviour in the background. The user prompt is the request the person types.

In reinforcement learning, what's the explore vs exploit trade-off?

Exploit what you already know works, or explore something new that might work better. Too much of either one gives worse results.

Why do LLMs hallucinate?

They're trained to produce likely-sounding text, not checked facts. When they don't know, a fluent guess can still look like the most likely answer.

Watch a tiny language model get built, word by word, in your browser with Cocoon's Micro LLM.

Open Micro LLM →