CS50 Notes, Source Code, and Section Materials
Authored by David J. Malan and the CS50 Staff (Brian Yu, Carter Zenke, Doug Lloyd). Mapped to CS50 assignment problems by our tutors.
HARVARD UNIVERSITY
Problem set walkthroughs in C, Python, SQL, and JavaScript with check50 and submit50 pass guarantees on every pset from Mario through Fiftyville. The number-one cause of failed CS50 submissions is the Cash greedy algorithm losing 1 cent on $4.20 because students multiply by 100.0 (float) instead of round to int before the modulo, the exact failure mode our tutors annotate inline. Verified CS graduates with prior CS50 TA experience, starting at $20 per pset, 12-hour average turnaround.
Course Overview
CS50 introduces computational thinking across 10 weeks plus a final project, using 4 languages in sequence: Scratch (week 0), C (weeks 1 through 5), Python (weeks 6 through 7), SQL (week 7), and HTML, CSS, and JavaScript (weeks 8 through 9). Week 0 covers algorithms and abstraction with Scratch. Weeks 1 through 4 drive C through Mario, Cash, Credit, Caesar, Substitution, Plurality, Tideman, and Runoff.
Week 5 introduces data structures (linked lists, hash tables, tries) through Speller. Weeks 6 and 7 pivot to Python with Sentimental ports, then DNA, then Hogwarts House sorting, then Movies with SQL. Week 8 ships Homepage with vanilla web.
Week 9 ends with Finance, a multi-route Flask app with SQL accounting. The course assesses through 10 problem sets graded by check50 (correctness) and style50 (style), a final project graded by 3 CS50 staff against a published rubric, and 9 lab notebooks graded for completion. Lectures are recorded weekly on Friday at Sanders Theatre and posted to cs50.harvard.edu.
The university-internal version (Harvard College and Harvard Extension School) carries the same content as edX CS50x with one difference: Harvard students complete a hackathon and a CS50 Fair in person, while edX learners submit the final project asynchronously.
Course Reading
Authored by David J. Malan and the CS50 Staff (Brian Yu, Carter Zenke, Doug Lloyd). Mapped to CS50 assignment problems by our tutors.
Authored by Glenn Brookshear and Dennis Brylow. Mapped to CS50 assignment problems by our tutors.
Authored by Matthew Justice. Mapped to CS50 assignment problems by our tutors.
Assignments
Nested for loops drawing an ASCII pyramid of `#` characters with a 2-space gap between left and right halves in the More variant. Tests check pyramid height 1 through 8 with check50 exact string match. The classic off-by-one: a height-8 pyramid needs 8 rows of leading spaces ranging from 7 down to 0, not 8 down to 1.
Cash applies greedy coin change with quarters, dimes, nickels, pennies. Credit validates a 13, 15, or 16-digit card via Luhn checksum and identifies AMEX, MasterCard, or Visa from prefix and length. check50 tests Cash with $0.41, $1.50, $4.20, and $9.75 against expected counts 4, 6, 18, 9.
Caesar shifts each plaintext alphabetic character by a single-integer key modulo 26, preserving case and ignoring non-alpha. Substitution accepts a 26-character key (validated for length, uniqueness, alphabetic-only) and maps a through z to the key positions. Both reject non-numeric or duplicate-character key arguments with usage error.
Three voting-algorithm psets in C with structs and arrays. Plurality picks the candidate with the most first-place votes. Runoff eliminates the lowest-ranked candidate iteratively until majority. Tideman locks pairwise preferences into a directed graph and walks the source to break ties without creating a cycle, the cycle-detection step is the hardest part of all of Pset 3.
Implement a spell-checker using a hash table over a 143,091-word dictionary. Required functions: load, check, size, unload. check50 compares output to staff solution byte-for-byte. The pset grades load time and check time against a benchmark: load under 0.2 seconds and check under 0.5 seconds for the largest test text (austerland.txt at 1.4 million characters) earns a clean run; over 1 second on load triggers a TA review.
Python ports of earlier C work plus 3 new psets. DNA matches a STR (short tandem repeat) profile against a CSV database to identify a person. Volume scales a WAV file by a constant factor with 44-byte header preservation. Filter applies grayscale, sepia, reflect, blur, and edge detection (Sobel operator) to BMP images. The Sobel edge filter is the per-pixel computation most students get wrong by clipping to 255 with min() instead of round().
SQL queries against an IMDB-derived SQLite database (movies.db) with 8 tables: movies, people, stars, directors, ratings, certifications, genres, writers. The 13 problems escalate from `SELECT * FROM movies WHERE year = 2008` (problem 1) to a 4-table JOIN finding actors who appeared with Kevin Bacon (problem 13). check50 compares row counts and column order against expected output.
Open-ended SQL forensics: 14 tables (crime_scene_reports, interviews, atm_transactions, phone_calls, bank_accounts, people, courthouse_security_logs, flights, airports, passengers) and one open question (who stole the CS50 duck and where did they flee). The pset grades the answer written into a one-line text file plus a SQL log proving the deduction path. No check50 autograder; graded by staff against the correct answer set (thief, accomplice, destination city).
Multi-route Flask web app simulating a stock portfolio with IEX Cloud API quote lookup, SQLite persistence, register and login routes with bcrypt password hashing, buy and sell routes with transaction logging, and a history page. Required routes: quote, buy, sell, history, register, plus a custom personal-touch route. check50 simulates a full buy-sell-history flow with a test user, validates session cookie behavior, and checks register form validation (username uniqueness, password confirmation).
A 3-week capstone built in any language or framework, scoped wider than any single pset but smaller than a thesis. Required deliverables: a README in the GitHub repo, a 1-minute video demo uploaded to YouTube, and a 5-minute live demo at the CS50 Fair (Harvard) or asynchronous submission (edX). Graded against 3 axes by CS50 staff: scope (is it pset-sized or bigger), polish (does it work without obvious bugs), and design choices (does the README justify framework selection).
Common Pitfalls
Pset 1 Mario More requires a pyramid where row i has (height - i - 1) leading spaces, i + 1 hashes, 2 gap spaces, then i + 1 hashes again. Students iterate from 1 to height instead of 0 to height - 1, producing a pyramid shifted right by 1 column. check50 fails on the first row (1 hash should sit immediately left of the gap, not indented one space).
The pset hands you a float dollar amount. Naive code multiplies by 100.0 and takes modulo against 25, 10, 5, 1. The bug: $4.20 stored as float is 4.1999999999999993, and `(int)(4.1999 * 100) = 419` cents, off by 1. The fix: use `roundf(dollars * 100)` to convert to cents before the greedy loop, or read as long long cents directly.
Caesar accepts an integer key from argv[1]. Naive code uses `atoi(argv[1])` which returns 0 on non-numeric input (so a key of "hello" silently encrypts with shift 0). The fix: iterate argv[1] character-by-character verifying isdigit, then convert with strtol and check errno for ERANGE. Also: keys above INT_MAX modulo 26 should reduce to key % 26 before the shift loop, not after.
Pset 3 Tideman ranks pairs by strength of victory, then locks each into a directed graph in order, skipping any pair that would create a cycle. Students implement the cycle check by walking the graph from the proposed edge winner and looking for the loser. The bug: depth-first search without a visited array enters an infinite loop on transitive locks. The fix: a recursive `check_cycle(target, current)` helper that returns true if target is reachable from current, called before adding each edge.
Pset 5 grades load time, check time, size, and unload time against the staff benchmark. Two failure modes dominate. The first: a hash function with too few buckets (under 26) produces 5,000-element chains on the large dictionary, blowing the 0.5-second check budget. The second: unload frees only the head node of each chain, leaking 143,091 minus N pointers and causing valgrind to flag 2 megabytes of unfreed allocations. The fix: a bucket count of at least 65,536, a polynomial hash like djb2, and an unload that walks each chain freeing every node before freeing the table.
Pset 6 DNA counts the longest run of a short tandem repeat (e.g. "AGAT") in a DNA sequence. Naive code uses `sequence.count(str)` which counts non-overlapping occurrences from a single starting position, not the longest consecutive run. The fix: a 2-pointer sliding-window scan that resets the counter on mismatch and tracks the max across all start positions in the sequence.
Pset 9 Finance routes user-submitted ticker symbols and share counts into SQL inserts. Students who use f-string interpolation (`f"INSERT INTO transactions VALUES ('{symbol}')"`) instead of parameterized queries (`db.execute("INSERT INTO transactions VALUES (?)", symbol)`) fail check50 SQL injection tests. The second bug: storing prices as REAL loses pennies; the fix is to store as INTEGER cents and divide for display.
submit50 packages the working directory into a tarball and uploads to CS50 servers via GitHub OAuth. Common failures: (1) a .gitignore that excludes the required filename, (2) trailing whitespace in helpers.c triggering style50 deductions that cascade, (3) an outdated submit50 binary on the cs50 codespace. The fix: `update50 && submit50 cs50/problems/2024/x/cash` and confirm the submission URL in the terminal before closing the tab.
Sample Work
Every CS50 deliverable ships with annotated code, an autograder transcript, and a line-by-line walkthrough. Browse anonymized samples to see what a delivered pset looks like before you submit.
Sample-work archive includes code, comments, autograder output, and the design-decision notes our tutors leave for each pset.
Browse sample workRelated Coverage
Valgrind-clean solutions for systems, sockets, and memory-allocator assignments, with ownership comments on every malloc and free. The most-deducted bug in Computer Systems labs (Berkeley CS61C, CMU 15-213, U of T CSC369, Manchester COMP25212, NUS CS2106, IIT Bombay CS347) is a missing NULL check after malloc that segfaults under low-memory test inputs, the exact failure mode our tutors catch with explicit defensive programming. Verified CS graduates from EPFL Lausanne, Purdue, U of Toronto, Manchester, NUS, and IIT, starting at $20 per task, 12-hour average turnaround.
Implementation, Big-O analysis, and JUnit edge-case tests for every structure from arrays through graphs. The number-one cause of failed Gradescope submissions in CS61B is iterator invalidation after a mid-traversal mutation, the exact failure mode our tutors annotate inline. Verified CS graduates from BITS Pilani, EPFL Lausanne, and Georgia Tech, starting at $20 per task, 12-hour average turnaround.
Sorting, dynamic programming, greedy, divide-and-conquer, and graph algorithms with formal complexity analysis. The hardest CS161 grading deduction is failing to prove the greedy-choice property for a problem that looks greedy but is not, the gap our tutors close with a worked exchange argument. Verified CS graduates from Georgia Tech, Purdue, and BITS Pilani, starting at $20 per task, 12-hour average turnaround.
FAQ
Reviewed By
Submit your CS50 assignment and get a verified CS tutor on it within 12 hours. Every delivery passes the autograder, ships with line-by-line comments, and includes a design-decision walkthrough so you can defend the work in office hours.
Submit CS50 Assignment