37 lines
1.1 KiB
Markdown
37 lines
1.1 KiB
Markdown
# Traveling Salesman Problem (TSP)
|
|
|
|
## What is the Traveling Salesman Problem?
|
|
|
|
Imagine you're a delivery person who needs to visit several houses in your neighborhood and then return home. You want to find the **shortest possible route** that visits every house exactly once and brings you back to where you started.
|
|
|
|
That's exactly what the Traveling Salesman Problem is about!
|
|
|
|
### Real-World Example
|
|
Let's say you need to deliver pizza to 4 houses:
|
|
- Your home: (0, 0)
|
|
- House A: (1, 0)
|
|
- House B: (1, 1)
|
|
- House C: (0, 1)
|
|
|
|
```
|
|
C ---- B
|
|
| |
|
|
| |
|
|
Home - A
|
|
```
|
|
|
|
You could go in many different orders:
|
|
- Home → A → B → C → Home
|
|
- Home → A → C → B → Home
|
|
- Home → B → A → C → Home
|
|
- ... and many more!
|
|
|
|
But which path is the shortest? That's what our algorithm finds out!
|
|
|
|
## How Our Algorithm Works 🔍
|
|
|
|
Our solution uses a "brute force" approach, which means:
|
|
**"Let's try EVERY possible path and pick the shortest one!"**
|
|
|
|
It's like trying on every shirt in your closet to find the one that fits best - not the fastest way, but it guarantees you'll find the perfect answer!
|