CPU Explorer

Dive inside the machine. Touch the bits. Bend the logic.
See how computers really think.

Welcome, Explorer

Every click will open a tiny universe inside your computer.
Flip real bits. Fire up logic gates. Watch the CPU pulse in real time.
Your journey into the hidden world of computation begins now.

Module 1
Bits & Binary
Flip switches. Watch numbers come alive.
Module 2
Logic Gates
AND, OR, NOT — build the mind of a machine.
Module 3
CPU Cycle
Watch the brain of the computer ignite.
Module 4
Memory & Pointers
Explore the memory grid. Click cells. Reveal data.
Module 5
Data Types
Meet the building blocks: ints, floats, chars, strings.
Module 6
Arrays & Lists
Solid sequences vs flexible chains.
Module 7
Stacks & Queues
Plates and lines — interactive data flow.
Module 8
Hashmaps
Instant lookup magic. Visualize collisions.
Module 9
Graphs & Trees
Nodes, edges, paths… the geometry of knowledge.
Module 10
Algorithms
Search, sort, conquer — see Big-O visually.
Module 11
Programming
Variables, functions, recursion… made simple.
Module 12
Machine Learning
Neurons, weights, accuracy — bring AI to life.
Module 13
Internet
Packets, IPs, DNS, HTTP — the world behind a click.
Module 14
Databases & SQL
Tables, joins, primary keys — see data relationships.

Bits & Binary

What is a Bit?

A bit is the smallest unit of data in computing. It can only be one of two values: 0 or 1. Think of it like a light switch - it's either OFF (0) or ON (1).

Try it! Click the switches:

0
0
0
0

Binary: 0000

Decimal: 0

What is a Byte?

A byte is a group of 8 bits. With 8 bits, you can represent 256 different values (0-255). This is why bytes are the fundamental unit of computer memory.

A full byte (8 bits):

0
0
0
0
0
0
0
0

Binary: 00000000

Decimal: 0

Hexadecimal: 0x00

Binary to Decimal Conversion

Each bit position represents a power of 2. From right to left: 1, 2, 4, 8, 16, 32, 64, 128...

For example: 00001010 in binary equals 10 in decimal (8 + 2 = 10)

Hexadecimal

Hexadecimal (base 16) is a shorthand for binary. Each hex digit represents 4 bits. Hex uses 0-9 and A-F.

Example: Binary 11111111 = Decimal 255 = Hex 0xFF

Logic Gates

What are Logic Gates?

Logic gates are the building blocks of digital circuits. They take one or more inputs (0 or 1) and produce a single output based on a logical operation.

AND Gate

The AND gate outputs 1 only if both inputs are 1.

0
AND
0
=
0
Input A Input B Output
000
010
100
111

OR Gate

The OR gate outputs 1 if either input is 1.

0
OR
0
=
0
Input A Input B Output
000
011
101
111

NOT Gate

The NOT gate inverts the input. 0 becomes 1, and 1 becomes 0.

0
NOT
=
1
Input Output
01
10

Why Gates Matter

Every operation your computer performs - from simple math to complex graphics - is built from billions of these tiny logic gates working together!

CPU Machine Cycle

The Four Steps of Execution

Every instruction your CPU executes goes through four steps. Click the button to watch the cycle animate!

1. FETCH

Get the next instruction from memory

2. DECODE

Figure out what the instruction means

3. EXECUTE

Perform the operation

4. STORE

Save the result back to memory

Current Step: Ready to start

What is GHz?

CPU speed is measured in GigaHertz (GHz). A 3 GHz processor can perform this cycle 3 billion times per second!

Each cycle is called a clock cycle, and the speed is called the clock speed.

Cores and Threads

Cores: Modern CPUs have multiple cores - essentially multiple processors working in parallel. A 4-core CPU can run 4 instructions simultaneously.

Threads: Each core can often handle 2 threads through a technology called hyper-threading, allowing even more parallelism.

Example: A 4-core, 8-thread CPU can work on 8 different tasks at the same time!

Memory & Pointers

RAM: A Grid of Bytes

Think of RAM as a huge grid of boxes. Each box can hold one byte, and each box has a unique address.

Click on any memory cell to select it:

Selected Address: None

Value: -

What is a Pointer?

A pointer is a variable that stores a memory address. Instead of holding data directly, it points to where the data is located.

Think of it like a street address - it doesn't contain your house, it just tells you where your house is!

Segmentation Fault

A segmentation fault happens when a program tries to access memory it's not allowed to touch. It's like trying to open someone else's mailbox - the system stops you!

int* ptr = NULL; // Pointer to nothing *ptr = 42; // CRASH! Can't write to address 0

Memory Leak

A memory leak occurs when a program allocates memory but forgets to free it. Over time, the program uses more and more RAM until it runs out!

Imagine renting storage units but never returning the keys - eventually you run out of money and storage space.

Stack vs Heap

Stack: Fast, automatic memory for local variables. Limited size. Like a stack of plates - last in, first out.

Heap: Slower, manual memory for dynamic allocation. Much larger. Like a warehouse where you can store things anywhere.

Data Types

Integers

Integers are whole numbers without decimal points. They can be positive, negative, or zero.

Common sizes: 8-bit, 16-bit, 32-bit, 64-bit

Example: int age = 25;

Floating Point Numbers

Floats and doubles store decimal numbers. They use scientific notation internally.

Example: float price = 19.99;

Why do floats cause errors?

Try this calculation: 0.1 + 0.2

In many programming languages, this equals 0.30000000000000004 instead of exactly 0.3! This happens because computers store decimals in binary, which can't perfectly represent some decimal fractions.

Characters

A character (char) stores a single letter, number, or symbol. Usually 1 byte (8 bits).

Characters are stored as numbers using encoding like ASCII or Unicode.

Example: char grade = 'A'; (stored as number 65)

Strings

A string is a sequence of characters. In most languages, it's an array of characters ending with a special null character.

Example: string name = "Alice";

Binary Representation

Enter a number to see its binary representation:

Arrays & Linked Lists

Arrays

An array is a continuous block of memory that stores multiple values of the same type.

Advantages: Fast access to any element (random access)

Disadvantages: Fixed size, inserting/deleting in the middle is slow

Array in Memory:

10
20
30
40
50

All elements are stored right next to each other in memory

Access time: O(1) - constant time!

Linked Lists

A linked list is a chain of nodes. Each node contains data and a pointer to the next node.

Advantages: Dynamic size, easy to insert/delete

Disadvantages: Slower access, uses more memory for pointers

Linked List Structure:

10 →
20 →
30 →
NULL

Each node points to the next one in memory

Access time: O(n) - must traverse from the start

When to Use Each?

Use Arrays: When you know the size ahead of time and need fast random access

Use Linked Lists: When size changes frequently or you need to insert/delete in the middle often

Stacks & Queues

Stack - LIFO (Last In, First Out)

A stack is like a stack of plates - you can only add or remove from the top.

Try it!

Common Uses:

  • Function call stack (how programs track function calls)
  • Undo functionality in applications
  • Browser back button
  • Expression evaluation (like calculating math)

Queue - FIFO (First In, First Out)

A queue is like a line at a store - first person in is the first person out.

Try it!

Common Uses:

  • Print job scheduling
  • Task processing (background jobs)
  • Breadth-first search in graphs
  • Buffering (video streaming, keyboard input)

Hashmaps

What is a Hashmap?

A hashmap (also called hash table or dictionary) provides super-fast lookup by using a special function to convert keys into array indices.

Think of it like a library catalog - instead of searching every book, you use the catalog number to go straight to the right shelf!

How It Works

1. You give it a key (like "apple")

2. A hash function converts the key to a number (like 42)

3. That number is the index in an array where the value is stored

4. Lookup is O(1) - instant!

Hash Table Visualization:

0
1
"apple" → 5
2
3
"banana" → 3
4
"cherry" → 7
5

Hash Collisions

Sometimes two different keys hash to the same index - this is called a collision.

Solutions:

  • Chaining: Store multiple items at the same index using a linked list
  • Open Addressing: Find the next available slot in the array

Collision with Chaining:

0
1
"apple" → 5 → "apricot" → 2
2

Both "apple" and "apricot" hashed to index 1, so they're chained together

Real-World Uses

  • Databases for fast lookups
  • Caching systems
  • Counting word frequencies
  • Removing duplicates from data
  • Implementing sets

Graphs & Trees

What is a Graph?

A graph is a collection of nodes (vertices) connected by edges. Graphs represent relationships between things.

Examples: Social networks (people connected by friendships), maps (cities connected by roads), web pages (linked by hyperlinks)

Binary Search Tree

A binary tree is a special type of graph where each node has at most 2 children. In a binary search tree, left children are smaller and right children are larger.

50
30
70
20
40
60
80

Finding a value is fast: O(log n) for balanced trees!

Breadth-First Search (BFS)

BFS explores a graph level by level, like ripples in water. It uses a queue.

Order for the tree above: 50 → 30 → 70 → 20 → 40 → 60 → 80

Uses: Finding shortest path, social network connections (friends of friends)

Depth-First Search (DFS)

DFS explores a graph by going as deep as possible before backtracking. It uses a stack.

Order for the tree above: 50 → 30 → 20 → 40 → 70 → 60 → 80

Uses: Maze solving, detecting cycles, topological sorting

Real-World Applications

  • GPS navigation (shortest path algorithms)
  • Social media friend suggestions
  • Recommendation systems
  • Compiler dependency resolution
  • Network routing

Algorithms

What is an Algorithm?

An algorithm is a step-by-step procedure to solve a problem. Think of it as a recipe!

Example: A recipe for making a sandwich is an algorithm for turning ingredients into food.

Big-O Notation

Big-O describes how the runtime of an algorithm grows as the input size increases.

Common Time Complexities:

O(1)
O(log n)
O(n)
O(n²)

Height represents how runtime grows with input size

O(1) - Constant: Same speed regardless of input size (accessing array by index)

O(log n) - Logarithmic: Cuts problem in half each time (binary search)

O(n) - Linear: Time grows proportionally with input (searching unsorted list)

O(n²) - Quadratic: Nested loops (comparing every item with every other item)

Binary Search

Binary search is a divide-and-conquer algorithm for finding an item in a sorted array.

How it works:

  1. Look at the middle element
  2. If it's your target, done!
  3. If target is smaller, search the left half
  4. If target is larger, search the right half
  5. Repeat until found
// Example: Finding 42 in [10, 20, 30, 40, 50, 60, 70] Step 1: Check middle (40) - too small, go right Step 2: Check middle of right half (60) - too big, go left Step 3: Check middle (50) - too big, go left Step 4: Check 42 - FOUND!

Binary search is O(log n) - incredibly fast! Finding an item in 1 billion elements takes only about 30 comparisons!

Why Algorithms Matter

The difference between O(n) and O(n²) might not matter for 10 items, but for 1 million items:

  • O(n): 1 million operations
  • O(n²): 1 TRILLION operations

Good algorithms can mean the difference between instant results and waiting hours!

Programming Foundations

Variables

A variable is a named container for storing data. Think of it as a labeled box.

// Different programming languages: // Python name = "Alice" age = 25 // JavaScript let name = "Alice"; let age = 25; // C char name[] = "Alice"; int age = 25;

Functions

A function is a reusable block of code that performs a specific task.

// Python function def greet(name): return "Hello, " + name // JavaScript function function greet(name) { return "Hello, " + name; } // Usage result = greet("Alice") // "Hello, Alice"

Recursion

Recursion is when a function calls itself. It's useful for solving problems that can be broken into smaller versions of themselves.

// Calculate factorial: 5! = 5 × 4 × 3 × 2 × 1 function factorial(n) { if (n <= 1) return 1; // Base case return n * factorial(n - 1); // Recursive call } factorial(5) // Returns 120

The Call Stack:

factorial(5) → 5 * factorial(4) → 4 * factorial(3) → 3 * factorial(2) → 2 * factorial(1) → 1 (base case - stop!) ← 2 * 1 = 2 ← 3 * 2 = 6 ← 4 * 6 = 24 ← 5 * 24 = 120

Stack Overflow

If recursion never reaches a base case, it keeps calling itself until the call stack runs out of memory - this is called stack overflow!

// DANGEROUS - infinite recursion! function broken() { return broken(); // Never stops! }

Compiled vs Interpreted

Compiled Languages (C, C++, Rust):

  • Code is translated to machine code before running
  • Faster execution
  • Need to compile before running

Interpreted Languages (Python, JavaScript):

  • Code is translated line-by-line while running
  • Slower execution but easier to develop
  • Run immediately without compilation

Machine Learning Basics

What is Machine Learning?

Machine Learning is teaching computers to learn from data instead of explicitly programming every rule.

Instead of saying "if temperature > 80, it's hot", you show the computer thousands of examples and it figures out the pattern!

Training vs Testing Data

Training Data: The examples you use to teach the model (like flashcards for studying)

Testing Data: New examples to see if the model actually learned (like the real exam)

You never test on the same data you trained on - that would be like taking the same exact exam you studied from!

Neural Networks

A neural network is inspired by how the brain works - lots of simple units (neurons) connected together can solve complex problems.

Simple Neural Network:

Input Layer → Hidden Layer → Output Layer

How Learning Works

1. Make a prediction with random weights (usually wrong at first)

2. Calculate the error - how wrong was the prediction?

3. Update the weights to reduce the error

4. Repeat thousands or millions of times

Over time, the model gets better and better at making accurate predictions!

Interactive Demo

Training Progress Simulator

Model Accuracy: 50%

Error Rate: 50%

Real-World Applications

  • Image recognition (face detection, self-driving cars)
  • Natural language processing (chatbots, translation)
  • Recommendation systems (Netflix, Spotify)
  • Fraud detection
  • Medical diagnosis

Internet Basics

What is the Internet?

The Internet is a global network of interconnected computers. It's not a cloud - it's physical cables, routers, and servers all over the world!

Key infrastructure: Fiber optic cables (including underwater cables between continents), data centers, cell towers, satellites

IP Addresses

Every device on the Internet has an IP address - like a mailing address for data.

IPv4 example: 192.168.1.1 (4 numbers, each 0-255)

IPv6 example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 (much longer, for more devices)

DNS - Domain Name System

DNS is like a phone book for the Internet. It converts human-readable names to IP addresses.

www.google.com

↓ DNS Lookup ↓

142.250.185.46

When you type "google.com", DNS converts it to an IP address so your computer knows where to connect!

TCP - Transmission Control Protocol

TCP breaks data into small packets, sends them, and reassembles them at the destination.

Why packets? Imagine sending a book by mail - you'd break it into chapters and mail them separately. If one gets lost, you only resend that chapter!

Data Transmission:

Your Message: "Hello World!"

↓ Broken into packets ↓

Packet 1: "Hell" Packet 2: "o Wo" Packet 3: "rld!"

↓ Reassembled at destination ↓

"Hello World!"

HTTP - HyperText Transfer Protocol

HTTP is the language browsers use to request web pages from servers.

// Your browser sends: GET /index.html HTTP/1.1 Host: www.example.com // Server responds: HTTP/1.1 200 OK Content-Type: text/html [webpage content]

HTTP Status Codes

200 OK: Success! Here's your webpage

404 Not Found: That page doesn't exist

500 Internal Server Error: Something broke on the server

403 Forbidden: You're not allowed to access this

301 Moved Permanently: This page moved to a new location

HTTPS - Secure HTTP

The "S" stands for Secure. HTTPS encrypts data so hackers can't read it in transit. Always look for the padlock in your browser!

Databases & SQL

What is a Database?

A database is an organized collection of data, stored in tables with rows and columns - like a spreadsheet on steroids!

Database Tables

Table: Collection of related data

Row: A single record (like one person)

Column: A field (like name, age, email)

Example: Users Table

ID Name Email Age
1 Alice [email protected] 25
2 Bob [email protected] 30
3 Charlie [email protected] 28

Primary Keys & Foreign Keys

Primary Key: A unique identifier for each row (like ID in the table above). No two rows can have the same primary key.

Foreign Key: A reference to a primary key in another table, creating relationships between tables.

Example: Orders Table (references Users)

Order_ID User_ID (FK) Product Price
101 1 Laptop 999
102 2 Mouse 25

User_ID links to the Users table - so we know Alice ordered the laptop!

SQL - Structured Query Language

SQL is the language for talking to databases. It's like asking questions in a very specific way.

-- Get all users SELECT * FROM users; -- Get just names and emails SELECT name, email FROM users; -- Get users older than 25 SELECT * FROM users WHERE age > 25; -- Get users sorted by age SELECT * FROM users ORDER BY age DESC; -- Add a new user INSERT INTO users (name, email, age) VALUES ('David', '[email protected]', 35); -- Update a user's age UPDATE users SET age = 26 WHERE id = 1; -- Delete a user DELETE FROM users WHERE id = 3;

JOINs - Combining Tables

JOINs let you combine data from multiple tables based on relationships.

-- Get all orders with user information SELECT users.name, orders.product, orders.price FROM orders JOIN users ON orders.user_id = users.id; Result: Name | Product | Price --------|---------|------ Alice | Laptop | 999 Bob | Mouse | 25

SQL Injection (Security Alert!)

SQL injection is a hacking technique where attackers insert malicious SQL code into input fields.

// DANGEROUS - don't do this! query = "SELECT * FROM users WHERE name = '" + userInput + "'"; // If hacker enters: Alice'; DROP TABLE users; -- // The query becomes: SELECT * FROM users WHERE name = 'Alice'; DROP TABLE users; --' // This deletes your entire users table! // SAFE - use parameterized queries: query = "SELECT * FROM users WHERE name = ?"; // The database safely escapes the input

Always validate and sanitize user input!

Why Databases Matter

  • Store millions/billions of records efficiently
  • Fast searching and filtering
  • Handle multiple users simultaneously
  • Ensure data integrity with transactions
  • Backup and recovery