Dive inside the machine. Touch the bits. Bend the logic.
See how computers really think.
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.
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).
Binary: 0000
Decimal: 0
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.
Binary: 00000000
Decimal: 0
Hexadecimal: 0x00
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 (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 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.
The AND gate outputs 1 only if both inputs are 1.
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The OR gate outputs 1 if either input is 1.
| Input A | Input B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The NOT gate inverts the input. 0 becomes 1, and 1 becomes 0.
| Input | Output |
|---|---|
| 0 | 1 |
| 1 | 0 |
Every operation your computer performs - from simple math to complex graphics - is built from billions of these tiny logic gates working together!
Every instruction your CPU executes goes through four steps. Click the button to watch the cycle animate!
Get the next instruction from memory
Figure out what the instruction means
Perform the operation
Save the result back to memory
Current Step: Ready to start
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: 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!
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: -
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!
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!
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: 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.
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;
Floats and doubles store decimal numbers. They use scientific notation internally.
Example: float price = 19.99;
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.
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)
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";
Enter a number to see its binary representation:
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
All elements are stored right next to each other in memory
Access time: O(1) - constant time!
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
Each node points to the next one in memory
Access time: O(n) - must traverse from the start
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
A stack is like a stack of plates - you can only add or remove from the top.
Common Uses:
A queue is like a line at a store - first person in is the first person out.
Common Uses:
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!
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!
Sometimes two different keys hash to the same index - this is called a collision.
Solutions:
Both "apple" and "apricot" hashed to index 1, so they're chained together
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)
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.
Finding a value is fast: O(log n) for balanced trees!
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)
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
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 describes how the runtime of an algorithm grows as the input size increases.
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 is a divide-and-conquer algorithm for finding an item in a sorted array.
How it works:
Binary search is O(log n) - incredibly fast! Finding an item in 1 billion elements takes only about 30 comparisons!
The difference between O(n) and O(n²) might not matter for 10 items, but for 1 million items:
Good algorithms can mean the difference between instant results and waiting hours!
A variable is a named container for storing data. Think of it as a labeled box.
A function is a reusable block of code that performs a specific task.
Recursion is when a function calls itself. It's useful for solving problems that can be broken into smaller versions of themselves.
The Call Stack:
If recursion never reaches a base case, it keeps calling itself until the call stack runs out of memory - this is called stack overflow!
Compiled Languages (C, C++, Rust):
Interpreted Languages (Python, JavaScript):
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 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!
A neural network is inspired by how the brain works - lots of simple units (neurons) connected together can solve complex problems.
Input Layer → Hidden Layer → Output Layer
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!
Model Accuracy: 50%
Error Rate: 50%
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
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 is like a phone book for the Internet. It converts human-readable names to IP addresses.
↓ DNS Lookup ↓
When you type "google.com", DNS converts it to an IP address so your computer knows where to connect!
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!
Your Message: "Hello World!"
↓ Broken into packets ↓
↓ Reassembled at destination ↓
"Hello World!"
HTTP is the language browsers use to request web pages from servers.
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
The "S" stands for Secure. HTTPS encrypts data so hackers can't read it in transit. Always look for the padlock in your browser!
A database is an organized collection of data, stored in tables with rows and columns - like a spreadsheet on steroids!
Table: Collection of related data
Row: A single record (like one person)
Column: A field (like name, age, email)
| ID | Name | Age | |
|---|---|---|---|
| 1 | Alice | [email protected] | 25 |
| 2 | Bob | [email protected] | 30 |
| 3 | Charlie | [email protected] | 28 |
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.
| 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 is the language for talking to databases. It's like asking questions in a very specific way.
JOINs let you combine data from multiple tables based on relationships.
SQL injection is a hacking technique where attackers insert malicious SQL code into input fields.
Always validate and sanitize user input!