"This is CS50!" - David J. Malan
Welcome to my CS50 journey! This repository contains comprehensive notes, code examples, and implementations from Harvard's CS50: Introduction to Computer Science course, taught by the legendary David J. Malan.
As David always emphasizes, CS50 isn't just about learning to codeโit's about understanding what's happening underneath the hood. This course teaches us to think computationally and solve problems methodically, building a strong foundation that transcends any single programming language.
- ๐ "Understanding underneath the hood" - We don't just use tools; we understand how they work
- ๐ง "Computational thinking" - Breaking down complex problems into manageable pieces
- ๐จ "Correctness, Design, Style" - The three pillars of good programming
- ๐ "This is less comfortable โ more comfortable" - Growth happens outside your comfort zone
- ๐ช "Algorithms in pseudocode" - Think first, code second
- ๐ข "Off by one errors" - Attention to detail matters
- ๐ "Big O notation" - Efficiency and scalability are crucial
- Binary representation - How computers really "think"
- Pseudocode - Planning before programming
- Visual programming with Scratch blocks
- Low-level programming - Understanding memory and pointers
- Functions and scope - Building reusable code
- Data types - Choosing the right tool for the job
- Memory layout - How data is actually stored
- Strings as arrays - Characters under the hood
- Command-line arguments - Programs that take input
- Big O notation - Measuring algorithmic efficiency
- Searching algorithms - Linear vs Binary search
- Sorting algorithms - Selection, Bubble, and Merge sort
- Recursion - Functions calling themselves
- Pointers - Direct memory access
- Dynamic memory allocation - malloc() and free()
- Memory leaks - What happens when you forget to clean up
- Linked lists - Dynamic memory allocation
- Trees and binary search trees - Hierarchical data
- Hash tables - Fast lookups with O(1) average time
- Tries - Efficient string storage and retrieval
- Stacks and queues - LIFO and FIFO data structures
- Python syntax - From C to Python transition
- Data structures - Lists, dictionaries, sets, tuples
- File I/O - Reading/writing files, CSV, JSON
- Libraries - Importing modules and packages
- Image processing - PIL for image manipulation
- Face recognition - Computer vision applications
- Generative AI - ChatGPT, image generation, and AI applications
- Decision trees - Classification algorithms and information gain
- Minimax algorithm - Game-playing AI with alpha-beta pruning
- Machine learning - Supervised and unsupervised learning concepts
- Neural networks - Deep learning and large language models
- Prompt engineering - Crafting effective AI prompts
- AI ethics - Hallucinations, bias, and responsible AI use
- Relational databases - Moving beyond flat files to structured data
- SQL syntax - CREATE, SELECT, INSERT, UPDATE, DELETE operations
- Database design - Schema creation, normalization, and relationships
- Primary and foreign keys - Data integrity and table relationships
- Joins and complex queries - Combining data from multiple tables
- Indexes - Performance optimization for large datasets
- Python integration - Using sqlite3 and database APIs
- Security - SQL injection prevention and parameterized queries
- Concurrency - Race conditions and transaction management
- Web protocols - HTTP, DNS, and how the internet works
- HTML for structure - Semantic markup, forms, tables, and accessibility
- CSS for style - Selectors, box model, flexbox, and responsive design
- JavaScript for behavior - DOM manipulation, events, and client-side interactivity
- Web APIs - Geolocation, local storage, and other browser capabilities
- Code Organization - The importance of separating structure, style, and behavior into different files
- Web programming basics - HTTP, client-server model, request/response cycle
- Flask microframework - Routing, views, and application structure
- HTML forms - Handling user input and validation
- Templates (Jinja2) - Dynamic content and code reuse
- Sessions and cookies - Maintaining state across requests
- SQLite integration - Persistent data storage
- APIs and JSON - Building and consuming web APIs
Languages: C, Python, SQL, HTML, CSS, JavaScript
Tools: VS Code, GitHub, Flask, SQLite, MySQL
Libraries: CS50, PIL, face_recognition, sqlite3, csv, json
Web Technologies: HTML5, CSS3, JavaScript ES6+, Responsive Design, DOM Manipulation
Databases: SQLite, relational database concepts
AI Concepts: Machine Learning, Neural Networks, Decision Trees, Minimax
CS50/
โโโ ๐ Lecture 0 - Scratch/
โ โโโ Scratch.txt
โโโ ๐ Lecture 1 - C/
โ โโโ C_Programming.txt
โ โโโ hello.c
โ โโโ calculator.c
โ โโโ discount.c
โ โโโ mario.c
โ โโโ conditions.c
โ โโโ loops.c
โ โโโ data_types.c
โโโ ๐ Lecture 2 - Arrays/
โ โโโ Arrays.txt
โ โโโ arrays_basic.c
โ โโโ strings.c
โ โโโ caesar.c
โ โโโ readability.c
โ โโโ substitution.c
โ โโโ argv.c
โ โโโ scores.c
โโโ ๐ Lecture 3 - Algorithms/
โ โโโ Algorithms.txt
โ โโโ linear_search.c
โ โโโ binary_search.c
โ โโโ selection_sort.c
โ โโโ bubble_sort.c
โ โโโ merge_sort.c
โ โโโ recursion.c
โ โโโ phonebook.c
โโโ ๐ Lecture 4 - Memory/
โ โโโ Memory.txt
โ โโโ addresses.c
โ โโโ copy.c
โ โโโ memory.c
โ โโโ swap.c
โ โโโ phonebook.c
โ โโโ files.c
โ โโโ linked_list.c
โ โโโ buffer_overflow.c
โโโ ๐ Lecture 5 - Data Structures/
โ โโโ Data_Structures.txt
โ โโโ linked_lists.c
โ โโโ binary_tree.c
โ โโโ hash_table.c
โ โโโ trie.c
โ โโโ stack.c
โ โโโ queue.c
โโโ ๐ Lecture 6 - Python/
โ โโโ Python.txt
โ โโโ hello.py
โ โโโ calculator.py
โ โโโ mario.py
โ โโโ phonebook.py
โ โโโ dna.py
โ โโโ cash.py
โ โโโ readability.py
โ โโโ data_structures.py
โ โโโ file_io.py
โ โโโ face_recognition.py
โโโ ๐ Lecture 7 - Artificial Intelligence/
โ โโโ Artificial_Intelligence.txt
โ โโโ decision_tree.py
โ โโโ minimax_tictactoe.py
โ โโโ simple_chatbot.py
โ โโโ prompt_engineering.py
โโโ ๐ Lecture 8 - SQL/
โ โโโ SQL.txt
โ โโโ create_database.sql
โ โโโ queries.sql
โ โโโ python_sql.py
โ โโโ race_conditions.py
โ โโโ csv_to_sql.py
โโโ ๐ Lecture 9 - HTML, CSS, JavaScript/
โ โโโ Web_Development.txt
โ โโโ bingo.html
โ โโโ homepage.html
โ โโโ form_validation.html
โ โโโ autocomplete.html
โ โโโ geolocation.html
โ โโโ ๐ css/
โ โ โโโ bingo.css
โ โ โโโ homepage.css
โ โ โโโ form_validation.css
โ โ โโโ autocomplete.css
โ โ โโโ geolocation.css
โ โโโ ๐ js/
โ โโโ bingo.js
โ โโโ homepage.js
โ โโโ form_validation.js
โ โโโ autocomplete.js
โ โโโ geolocation.js
โโโ ๐ Lecture 10 - Flask/
โ โโโ forms_app/
โ โ โโโ app.py
โ โ โโโ templates/
โ โ โโโ index.html
โ โโโ frosh_ims_app/
โ โ โโโ app.py
โ โ โโโ templates/
โ โ โโโ index.html
โ โโโ shows_app/
โ โโโ app.py
โ โโโ templates/
โ โโโ index.html
โโโ README.md
By the end of CS50, students will:
-
โ Think computationally and solve problems methodically
-
โ Understand computer science fundamentals that transcend programming languages
-
โ Write correct, well-designed, and stylish code
-
โ Debug effectively using proper techniques and tools
-
โ Implement fundamental algorithms and data structures
-
โ Manage memory and understand system-level programming
-
โ Build web applications from front-end to back-end
-
forms_app/ โ A simple app showing how to handle HTML forms, process user input, and display responses. Great for learning about routing, request methods, and templates.
-
frosh_ims_app/ โ A registration system for intramural sports, demonstrating form validation, user feedback, and storing submitted data. This mirrors the classic CS50 โFrosh IMsโ example.
-
shows_app/ โ An app that queries a SQLite database and displays TV show data using templates. Illustrates database integration and dynamic content rendering.
Each app is self-contained with its own app.py
and templates/
folder. To run an app, navigate to its directory and execute:
python app.py
You can then visit the app in your browser at http://127.0.0.1:5000/
.
Each week includes hands-on problem sets that reinforce the concepts:
- ๐ฎ Scratch Project - Interactive game or animation
- ๐ข Mario Pyramids - ASCII art with nested loops
- ๐ Caesar/Substitution Ciphers - Cryptography fundamentals
- ๐ Readability - Text analysis algorithms
- ๐ณ๏ธ Plurality/Runoff - Election simulation systems
- ๐พ Filter - Image processing and manipulation
- ๐ Speller - Hash tables and spell checking
- ๐ง Memory Recovery - Digital forensics and file systems
- ๐ Dynamic Phonebook - Memory management and data structures
- ๐ณ Family Trees - Binary search trees and genealogy
- ๐ Dictionary - Trie implementation for fast word lookup
- ๐งฌ DNA Analysis - String processing and pattern matching
- ๐ญ Face Recognition - Computer vision and image processing
- ๐ฐ Cash/Credit - Greedy algorithms and validation
- ๐ฏ Tic-Tac-Toe AI - Minimax algorithm implementation
- ๐ค Chatbot - Natural language processing basics
- ๐๏ธ Movies Database - SQL queries and database design
- ๐ Fiftyville Mystery - SQL detective work with complex queries
- ๐ Homepage Portfolio - Building a personal website with HTML, CSS, and JS
- โ Form Validation Demo - Client-side validation using JavaScript and Regex
- ๐ Geolocation App - Using browser APIs to get user location
-
Clone the repository:
git clone <repository-url> cd CS50
-
Compile C programs:
clang -o program program.c -lcs50 ./program
-
Run Python programs:
python program.py
-
Execute SQL scripts:
sqlite3 database.db < script.sql
-
Open HTML files:
# Simply open in your web browser (e.g., double-click the file). # All CSS and JS are linked externally for best practice.
-
Install Python dependencies (for advanced programs):
pip install cs50 pillow face-recognition sqlite3
-
Follow along with lectures using the organized notes and code examples
"The best way to learn to program is to program."
"Programming is not about what you know; it's about what you can figure out."
"Don't be afraid to break things. That's how you learn."
"In programming, there's often more than one way to solve a problem. Focus on correctness first, then optimize."
"AI is a tool to augment human intelligence, not replace human judgment."
"Understanding what's underneath the hood applies to AI too - know how these systems work."
"Databases are just fancy filing cabinets - but the organization makes all the difference."
"SQL injection is like leaving your front door wide open - always sanitize your inputs!"
"The web is just computers talking to each other. HTML provides the nouns, CSS the adjectives, and JavaScript the verbs."
Feel free to:
- ๐ Suggest improvements to notes
- ๐ Report errors or typos
- ๐ก Share alternative implementations
- ๐ฏ Add more practice problems
- ๐ฌ Discuss CS50 concepts and problems
- ๐ค Ask questions about implementations
- ๐ฏ Share learning experiences
- ๐ Celebrate coding victories!
Building tomorrow's problem solvers, one algorithm at a time.
Happy Coding! ๐โจ
This repository is a tribute to CS50's incredible teaching methodology and David Malan's inspiring approach to computer science education. Understanding what's underneath the hood has never been more engaging!