Heuristics & Shortcuts
A heuristic is a rule of thumb — a quick, practical approach that gives you a good-enough answer without exhaustive analysis. Heuristics do not guarantee the best result, but they save enormous amounts of time and effort. We use them constantly, often without realizing it.
The Everyday Version
Shopping Decisions
You use heuristics every time you go to a store.
"If the line is long, try another register."
- Does not guarantee the other line is faster
- But it works most of the time
- Much better than standing still and calculating
the exact speed of each cashier
"If a product has thousands of good reviews, it is probably fine."
- Does not guarantee quality
- But it filters out the worst options quickly
- Much better than researching every product for hours
"If the store brand looks the same, buy the store brand."
- Not always identical quality
- But saves money with minimal risk
- Works especially well for basics like sugar or flour
Weather Decisions
"If it looks like rain, bring an umbrella."
- You do not check the barometric pressure
- You do not analyze satellite imagery
- You glance at the sky and make a call
- Right most of the time. Occasionally you carry
an umbrella on a sunny day. Acceptable cost.
"If it was cold yesterday, dress warm today."
- Weather changes, so this is imperfect
- But it is right more often than wrong
- Takes zero effort compared to checking forecasts
Navigation
"If traffic looks bad on the highway, take side streets."
- Side streets might also be congested
- But highways with visible congestion rarely clear up fast
- Quick decision, usually reasonable outcome
"If you are lost, head toward the tallest buildings."
- Works in most cities for finding the center
- Not always what you want
- But better than wandering randomly
Social Heuristics
We even use heuristics for social situations:
"If someone crosses their arms, they might be defensive."
- Not always true (they might just be cold)
- But useful as a quick read of a situation
"If a restaurant is empty at dinner time, be cautious."
- Could be new, or have odd hours
- But empty restaurants at peak time often signal a problem
Why Heuristics Work
Heuristics succeed because of a key insight: you do not need the optimal answer for most decisions.
Decision spectrum:
Random guess Heuristic Optimal solution
|---------------------|---------------------|
0% accuracy ~80% accuracy 100% accuracy
0 effort Low effort High effort
The jump from random to heuristic is huge.
The jump from heuristic to optimal is small.
The effort difference is enormous.
Most of life operates in the heuristic zone. You do not calculate the optimal breakfast. You eat what you usually eat, and it works fine.
When Heuristics Fail
Every heuristic has failure modes. Recognizing them is just as important as using them.
"Buy the cheapest option"
- Works for: Commodities (salt, paper towels)
- Fails for: Safety equipment, tools you use daily
"If everyone is doing it, it must be right"
- Works for: Choosing popular restaurants in a new city
- Fails for: Financial bubbles, crowd panic
"Go with your gut"
- Works for: Decisions in your area of expertise
- Fails for: Decisions where your biases mislead you
(e.g., estimating probability, unfamiliar domains)
Connecting to Technology
Caching
Caching is a heuristic: assume recently used data will be used again soon.
The heuristic: "If you asked for it recently,
you will probably ask for it again."
Web browser cache:
- First visit to a website: Download everything (slow)
- Second visit: Use cached copies of images,
scripts, and styles (fast)
- Heuristic assumption: The website has not changed
since your last visit
When it works: Most of the time. Websites do not
change every minute.
When it fails: The website updated but you see
the old version. That is why "clear your cache"
is a common troubleshooting step.
Common caching heuristics:
LRU (Least Recently Used):
- Evict the item that has not been used in the longest time
- Assumption: Old items are less likely to be needed
- Works well for most access patterns
LFU (Least Frequently Used):
- Evict the item used the fewest times
- Assumption: Rarely used items are less important
- Works well when some items are consistently popular
TTL (Time To Live):
- Expire items after a fixed time period
- Assumption: Data becomes stale after a while
- Simple and predictable
Greedy Algorithms
A greedy algorithm makes the locally optimal choice at each step, hoping it leads to a globally good result.
Everyday example: Making change for $0.67
Greedy approach (use the biggest coin that fits):
- $0.67 → use a quarter (25c) → $0.42 remaining
- $0.42 → use a quarter (25c) → $0.17 remaining
- $0.17 → use a dime (10c) → $0.07 remaining
- $0.07 → use a nickel (5c) → $0.02 remaining
- $0.02 → use two pennies (1c + 1c) → done
- Total: 6 coins
This greedy approach gives the optimal answer for
standard US coins. But for unusual coin systems,
greedy can fail.
Coin system: 1c, 3c, 4c
Make change for 6c:
- Greedy: 4c + 1c + 1c = 3 coins
- Optimal: 3c + 3c = 2 coins
In tech, greedy algorithms are used when finding the perfect solution takes too long:
Job scheduling:
- Hundreds of tasks, limited machines
- Optimal scheduling is computationally expensive
- Greedy: Assign each task to the least loaded machine
- Result: Not perfect, but fast and usually close enough
Approximation Algorithms
When the exact answer would take too long to compute, use an algorithm that guarantees a "close enough" result.
The Traveling Salesperson Problem:
- Visit 50 cities, find the shortest route
- Exact solution: Check all possible routes
(astronomical number of combinations)
- Approximation: Use a "nearest neighbor" heuristic
(always go to the closest unvisited city)
- Result: Usually within 25% of optimal
- Time: Seconds instead of centuries
Real-world application:
- Delivery route planning (UPS, FedEx)
- Circuit board wire routing
- DNA sequencing
- Network routing
A/B Testing as a Heuristic
A/B testing uses a shortcut to decide what works: try both options and measure.
Traditional approach:
- Research extensively
- Survey customers
- Build detailed models
- Predict which design is better
- Launch the predicted winner
A/B testing heuristic:
- Build both versions
- Show version A to half your users
- Show version B to the other half
- Measure which performs better
- Use the winner
Why this is a heuristic:
- You do not need to understand WHY one works better
- You just need to know THAT it works better
- Faster and more reliable than prediction
Load Balancing Heuristics
Round Robin:
- Send each request to the next server in line
- Heuristic: All servers are roughly equal
- Simple, works when servers are similar
Least Connections:
- Send to the server with fewest active requests
- Heuristic: Fewer connections means more capacity
- Works better when requests vary in complexity
Random:
- Pick a server at random
- Heuristic: Randomness distributes load evenly over time
- Surprisingly effective and extremely simple
Building Your Own Heuristics
Good heuristics share common traits:
1. Based on patterns that hold most of the time
- "Websites get more traffic on weekday mornings"
- True often enough to be useful for planning
2. Simple enough to apply quickly
- "If the build takes longer than 10 minutes, something
is probably wrong"
- No calculation needed
3. Have a known failure rate you accept
- "Check the top 3 results, not all 100"
- You might miss something, but you save a lot of time
4. Include a fallback for when they fail
- "Use the cache, but verify every 5 minutes"
- Heuristic handles normal cases, fallback handles exceptions
Common Pitfalls
- Treating heuristics as rules. A heuristic is a guide, not a law. When circumstances change, the heuristic might not apply.
- Using heuristics for high-stakes, one-time decisions. Rules of thumb work best for repeated, low-stakes decisions. For rare, irreversible choices, invest in deeper analysis.
- Ignoring failure modes. Every heuristic fails in some situations. Know when yours breaks down.
- Stacking heuristics without checking. Using one shortcut after another can compound errors. Periodically verify against real data.
- Confusing familiarity with correctness. "We have always done it this way" is a heuristic that resists improvement.
- Over-relying on caching. Cached data can be stale. Without expiration or invalidation, caches become sources of bugs.
Key Takeaways
- Heuristics are rules of thumb that trade perfection for speed. They give good-enough answers with minimal effort.
- Most daily decisions are already heuristic-driven. You do not optimize — you use shortcuts that work well enough.
- In technology, heuristics power caching, load balancing, greedy algorithms, and approximation algorithms.
- The value of a heuristic is in the gap between random guessing and exhaustive analysis — that gap is usually large.
- Every heuristic has failure modes. Know what yours are and have a fallback plan.
- The best heuristics are simple, based on real patterns, and include a way to check when they are wrong.