Algorithms Visualized

Watch code think

1

What is an Algorithm?

An algorithm is just a recipe - a set of steps to solve a problem. Making a sandwich? That's an algorithm. Finding a word in a dictionary? Algorithm. Sorting your playlist by name? You guessed it - algorithm!

💡 Key Insight

The same problem can often be solved by different algorithms. Some are fast, some are slow, some use lots of memory. Computer scientists spend their careers finding better algorithms!

2

The Great Sorting Race

Sorting is one of computing's most studied problems. Watch different algorithms race to sort the same data. All algorithms run to completion so you can see just how much faster the efficient ones really are!

Fast
0.0s
Elapsed Time
0/5
Finished
Ready
Status
📊 Algorithm Complexities
Bubble Sort
O(n²)
Selection Sort
O(n²)
Insertion Sort
O(n²)
Quick Sort
O(n log n)
Merge Sort
O(n log n)
Fun Fact

O(n²) algorithms (Bubble, Selection, Insertion) compare each element to every other element. With 100 items, that's up to 10,000 comparisons!

O(n log n) algorithms (Quick, Merge) use "divide and conquer" - they split the problem in half repeatedly. With 100 items, that's only about 700 comparisons. 14x fewer!

3

Why Some Code is Slow

Imagine you need to find a specific card in a deck. You could check every card one by one... or you could be smarter about it. Let's see the difference!

?
Finding Number
0
Boxes Checked
Pick a method!
Status
🎯 This is Big O!

Programmers use Big O to describe this difference:

O(n) = "Check every box" - With 1000 boxes, check up to 1000 times
O(log n) = "Smart search" - With 1000 boxes, only ~10 checks needed!

The "n" just means "how many items you have." As n gets bigger, the difference becomes HUGE.

📈 See How They Scale

100

📚 See All Big O Types (Advanced)
O(1)
Instant

Like knowing exactly which locker is yours. Always 1 step.

O(log n)
Smart Search

Like the guessing game - cut possibilities in half each time.

O(n)
One by One

Check everything once. 100 items = 100 checks.

O(n²)
Danger Zone!

Compare everything to everything. 100 items = 10,000 checks!

4

Linear vs Binary Search

Finding a number in a sorted list: should you check every item, or be clever about it? Watch linear search plod through vs binary search's magical halving technique!

42
Looking For
0
Steps Taken
Ready
Status
Fun Fact

Binary search is like finding a name in a phone book: open to the middle, check if your name is before or after, then repeat with half the book. A 1000-page book takes at most 10 checks!

5

Pathfinding: A* Algorithm

How does GPS find the fastest route? The A* algorithm! It explores possibilities while always heading toward the goal. Click to add walls, then watch it find the path.

Start
End
Wall
Explored
Final Path
0
Cells Explored
0
Path Length
🚗 Used Everywhere

A* and its variants power Google Maps, game AI (enemies chasing you!), robot navigation, and even protein folding simulations. It's one of the most important algorithms ever invented.

6

Sorting Playground

Pick any algorithm and watch it work step by step. See exactly how each one approaches the sorting problem differently.

0
Comparisons
0
Swaps
Ready
Status

Algorithm Explorer!

You've seen the invisible logic that powers every app, game, and website.

0
Races Run
0
Paths Found
0
Time Exploring

Algorithms are Recipes

Step-by-step instructions that solve problems - from making sandwiches to sorting data.

Big O Matters

O(n log n) algorithms can be thousands of times faster than O(n²) with large data.

Divide and Conquer

The fastest algorithms split problems in half repeatedly instead of checking everything.

Algorithms Are Everywhere

GPS, games, search engines, social media - all powered by algorithms running millions of times per second.

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction