🌍 CS50x: Introduction to Computer Science · subject

CS50x: Introduction to Computer Science Artificial Intelligence Syllabus

The Artificial Intelligence syllabus for CS50x: Introduction to Computer Science in full: 3 chapters and 8 topics, every one listed below, plus 50 Artificial Intelligence flashcards with answers.

3Chapters
8Topics
50Flashcards

Artificial Intelligence syllabus: all 3 chapters

Expand any chapter to see its topics and sub-topics.

  1. Foundations of AI

    2 topics
    • Decision Trees
    • Minimax
  2. Machine Learning

    3 topics
    • Supervised Learning
    • Reinforcement Learning
    • Neural Networks
  3. Large Language Models

    3 topics
    • How LLMs Work
    • Prompt Engineering
    • Hallucinations and Limitations

CS50x: Introduction to Computer Science Artificial Intelligence flashcards — 50 questions with answers

  1. In AI, what is a decision tree?

    A model that reaches a decision by asking a sequence of questions: each internal node tests a condition, each branch represents an answer to that condition, and each leaf node represents a final decision or action.

  2. How does a decision tree translate directly into code?

    As nested conditional (if–elif–else) statements: each question in the tree becomes a condition, and each leaf becomes the action executed when the chain of conditions leads there.

  3. Give the classic decision tree for a paddle-game AI (e.g., Breakout/Pong).

    Ask: "Is the ball to the left of the paddle?" If yes, move the paddle left. Otherwise ask: "Is the ball to the right of the paddle?" If yes, move right. Otherwise, do not move.

  4. What is the main limitation of hand-coded decision trees, and what does it motivate?

    For complex problems the number of cases explodes, making it infeasible for a programmer to enumerate every rule by hand. This motivates machine learning, where the computer learns patterns from data instead of following explicitly written rules.

  5. In a decision tree, what is the difference between an internal node and a leaf node?

    An internal node contains a question or condition that splits into branches based on the answer; a leaf node is a terminal node containing the final decision, classification, or action with no further branching.

  6. Contrast a hand-written decision tree with a machine learning approach to the same problem.

    A decision tree encodes rules explicitly programmed by a human, so its behavior is fixed and interpretable. A machine learning model infers its own rules from data, so it can handle far more complex patterns but requires training data and may be less interpretable.

  7. What is the minimax algorithm?

    An algorithm for adversarial, turn-based games in which one player (MAX) tries to maximize the game's score while the opponent (MIN) tries to minimize it; the algorithm recursively explores possible moves to choose the optimal one assuming the opponent also plays optimally.

  8. In minimax for tic-tac-toe, what utility values are typically assigned to terminal states?

    A win for the maximizing player (X) is $+1$, a win for the minimizing player (O) is $-1$, and a tie is $0$.

  9. State the minimax value function as a recursive formula.

    $$V(s)=\begin{cases} \text{Utility}(s) & \text{if } s \text{ is terminal} \\ \max_{a} V(\text{Result}(s,a)) & \text{if it is MAX's turn} \\ \min_{a} V(\text{Result}(s,a)) & \text{if it is MIN's turn} \end{cases}$$

  10. How does minimax decide which move to make from the current state?

    It simulates every possible move, recursively computes the value of each resulting state all the way to terminal states (assuming both players play optimally), and then picks the move whose resulting state has the best guaranteed value for the current player.

  11. Why is plain minimax feasible for tic-tac-toe but not for chess?

    Tic-tac-toe has only about $255{,}168$ possible games, so the full game tree can be searched. Chess has roughly $10^{123}$ possible games (the Shannon number), far too many states for any computer to explore exhaustively.

  12. Name two standard optimizations that make minimax practical for large games.

    (1) Alpha–beta pruning: skip branches that cannot affect the final decision, without changing the result. (2) Depth-limited minimax: search only a fixed number of moves ahead and apply a heuristic evaluation function to estimate the value of non-terminal states.

  13. In minimax, which player is MAX and which is MIN, and what does each assume about the other?

    MAX is the player trying to achieve the highest utility; MIN is the opponent trying to achieve the lowest. Each assumes the other plays optimally, so minimax computes the best move against a perfect adversary.

  14. Define supervised learning.

    A machine learning paradigm in which a model is trained on a dataset of labeled input–output pairs, learning a function $f: X \to Y$ that maps inputs to correct outputs so it can predict labels for new, unseen inputs.

  15. What is the difference between classification and regression in supervised learning?

    Classification predicts a discrete category (e.g., spam vs. not spam, rain vs. no rain), while regression predicts a continuous numeric value (e.g., a price or temperature).

  16. In supervised learning, what are training data and labels?

    Training data are the example inputs (feature values) shown to the model during learning; labels are the known correct outputs attached to each example, which the model uses as the ground truth to learn from.

  17. How does nearest-neighbor classification work?

    To classify a new data point, find the single training example closest to it (by a distance measure in feature space) and assign the new point that neighbor's label.

  18. How does $k$-nearest-neighbors ($k$-NN) improve on 1-nearest-neighbor?

    Instead of trusting one closest point, $k$-NN looks at the $k$ closest training examples and assigns the label held by the majority of them, making the classifier more robust to noisy points and outliers.

  19. What is overfitting in machine learning?

    When a model fits its training data too closely — capturing noise and idiosyncrasies rather than the general pattern — so it performs very well on training data but poorly on new, unseen data.

  20. Give two classic examples of supervised learning tasks with their inputs and outputs.

    (1) Spam detection: input = features of an email, output = the category spam or not spam (classification). (2) Weather prediction: input = measurements like humidity and air pressure, output = whether it will rain (classification) or how much (regression).

Show the other 30 Artificial Intelligence flashcards
  1. Define reinforcement learning (RL).

    A learning paradigm in which an agent learns from experience by interacting with an environment: it takes actions, receives rewards for good outcomes and penalties for bad ones, and gradually learns a strategy (policy) that maximizes cumulative reward.

  2. Name the five core components of a reinforcement learning problem.

    Agent (the learner/decision-maker), environment (the world it acts in), state (the current situation), action (a choice the agent makes), and reward (numeric feedback signaling how good the action's outcome was).

  3. Describe the interaction loop in reinforcement learning.

    The agent observes the current state, chooses an action, the environment transitions to a new state, and the agent receives a reward (or punishment). This state $\to$ action $\to$ reward cycle repeats, and the agent updates its behavior to earn more reward over time.

  4. What is the exploration vs. exploitation tradeoff in reinforcement learning?

    Exploitation means choosing actions already known to yield high rewards; exploration means trying new actions that might lead to even better rewards. An agent must balance both: too much exploitation misses better strategies, too much exploration wastes time on poor actions.

  5. How does reinforcement learning differ from supervised learning?

    Supervised learning requires labeled examples of correct outputs for each input. Reinforcement learning has no labeled answers; the agent only receives reward signals — often delayed — from its own trial-and-error interaction with the environment.

  6. Give two examples of problems well suited to reinforcement learning.

    Training game-playing agents (e.g., learning Nim or Go, as in AlphaGo, by playing many games and being rewarded for wins) and robotics tasks like teaching a robot to walk, where success is rewarded and falling is penalized.

  7. What biological system inspired artificial neural networks, and what is the analogy?

    The brain's network of neurons. Artificial units are analogous to neurons, and the weighted connections between units are analogous to synapses: each unit receives signals, and if the combined input is strong enough it "activates" and passes a signal onward.

  8. What are the three types of layers in a typical neural network?

    The input layer (receives the feature values), one or more hidden layers (intermediate units that learn internal representations), and the output layer (produces the final prediction).

  9. Write the formula for the output of a single artificial neuron with inputs $x_1,\dots,x_n$.

    $$h(x) = g\left(\sum_{i=1}^{n} w_i x_i + b\right)$$ where $w_i$ are the weights, $b$ is the bias, and $g$ is the activation function applied to the weighted sum.

  10. What is an activation function? Give two common examples with their formulas.

    A function applied to a unit's weighted sum that determines its output and introduces non-linearity. Examples: the sigmoid $\sigma(x)=\frac{1}{1+e^{-x}}$, which squashes values into $(0,1)$, and ReLU, $g(x)=\max(0,x)$, which passes positive values and zeroes out negatives.

  11. How is a neural network trained, at a high level?

    By gradient descent: the network makes predictions on training data, a loss function measures the error, and the weights are repeatedly adjusted in the direction that decreases the loss, i.e., $w \leftarrow w - \alpha \cdot \frac{\partial L}{\partial w}$, where $\alpha$ is the learning rate.

  12. What is backpropagation?

    The algorithm for training multilayer neural networks: it propagates the output error backward through the network, layer by layer, using the chain rule to compute the gradient of the loss with respect to every weight, so hidden-layer weights can be updated by gradient descent.

  13. What is a deep neural network?

    A neural network with multiple hidden layers between input and output. Each successive layer can learn increasingly abstract features, which is what "deep learning" refers to.

  14. Why are hidden layers and non-linear activations necessary in neural networks?

    A single unit with a linear function can only learn linearly separable decision boundaries. Hidden layers combined with non-linear activation functions allow the network to model complex, non-linear relationships between inputs and outputs.

  15. At its core, what task does a large language model (LLM) perform?

    Next-token prediction: given a sequence of text (the context), it outputs a probability distribution over the vocabulary for the most likely next token, then repeats this process token by token to generate text.

  16. What is a token in the context of LLMs?

    The basic unit of text an LLM processes — often a word, part of a word, or punctuation mark. Text is split into tokens before being fed to the model, and models have a maximum context window measured in tokens.

  17. What neural network architecture underlies modern LLMs, and what is its key mechanism?

    The transformer architecture, whose key mechanism is attention: it lets the model weigh how relevant every other token in the context is when interpreting or generating each token, capturing long-range relationships between words.

  18. What are word embeddings?

    Representations of tokens as high-dimensional numeric vectors that capture meaning: words with similar meanings map to vectors that are close together, allowing the model to compute with semantic relationships mathematically.

  19. How is an LLM trained, at a high level?

    In pretraining, the model is shown massive text corpora and its billions of weights (parameters) are tuned by gradient descent to predict the next token accurately. It is then typically fine-tuned — e.g., with reinforcement learning from human feedback (RLHF) — to be more helpful and follow instructions.

  20. Why does the attention mechanism matter for understanding a sentence like "The dog didn't cross the street because it was too tired"?

    Attention lets the model determine which earlier word "it" refers to (the dog, not the street) by assigning high relevance weights between "it" and "dog," resolving ambiguity using the whole context rather than only nearby words.

  21. What is the temperature parameter in LLM text generation?

    A setting that controls randomness when sampling the next token from the probability distribution: low temperature makes the model pick the most likely tokens (more deterministic, focused output), while high temperature flattens the distribution (more varied, creative output).

  22. What is prompt engineering?

    The practice of deliberately crafting the input text (prompt) given to an LLM — its wording, structure, context, and examples — to steer the model toward more accurate, relevant, and useful outputs.

  23. What is the difference between a system prompt and a user prompt?

    A system prompt is an instruction set by the developer that defines the model's role, rules, and behavior for the whole conversation (e.g., "You are a helpful tutor; never give away answers"). A user prompt is the message the end user actually types for the model to respond to.

  24. Compare zero-shot and few-shot prompting.

    Zero-shot prompting asks the model to perform a task with instructions only and no examples. Few-shot prompting includes a handful of worked input–output examples in the prompt, which usually improves accuracy because the model can imitate the demonstrated pattern.

  25. What is chain-of-thought prompting and why does it help?

    Prompting the model to reason step by step (e.g., "think through this step by step") before giving its final answer. Generating intermediate reasoning tokens improves performance on multi-step problems like math and logic, since each step conditions the next.

  26. Why does adding context and constraints to a prompt improve LLM output?

    Because the model generates text conditioned on everything in its context window: relevant background, explicit requirements, desired format, and examples narrow the space of plausible continuations, making the statistically likely output also the correct and useful one.

  27. What is a hallucination in the context of LLMs?

    When a model confidently generates text that is false or fabricated — invented facts, citations, dates, or events — that sounds plausible and fluent but does not correspond to reality.

  28. Why do LLMs hallucinate?

    Because they are trained only to produce statistically plausible next tokens, not to verify truth: they have no built-in fact database or fact-checking step, so when the training data is sparse or the question is ambiguous, a fluent but false continuation can be the most probable output.

  29. Name three key limitations of LLMs besides hallucination.

    (1) Knowledge cutoff: they know nothing about events after their training data ends. (2) Bias: they can reproduce biases present in their training text. (3) No true understanding or guaranteed reasoning: they can fail at arithmetic, logic, and consistency, and they cannot verify their own claims.

  30. What strategies help mitigate hallucinations when using an LLM?

    Verify important claims against authoritative sources; ask the model for citations and check them; ground the model with retrieved documents (retrieval-augmented generation, RAG) or provide the relevant facts in the prompt; and avoid relying on unverified output for high-stakes decisions.

CS50x: Introduction to Computer Science Artificial Intelligence FAQ

What is in the CS50x: Introduction to Computer Science Artificial Intelligence syllabus?

CS50x: Introduction to Computer Science Artificial Intelligence is split into 3 chapters: Foundations of AI, Machine Learning and Large Language Models. Together they contain 8 topics.

How many chapters are in CS50x: Introduction to Computer Science Artificial Intelligence?

3 chapters, containing 8 topics. The largest chapter is Machine Learning, with 3 topics.

Are there flashcards for CS50x: Introduction to Computer Science Artificial Intelligence?

Yes — a 50-card Artificial Intelligence deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.