How our 'Hot Picks' Algorithm Works: Finding Travel Gems with Greedy Optimization
A deep dive into the engineering behind our Hot Picks algorithm. Learn how we use C++, greedy search heuristics, and temporal bucketing to find the world's best multi-city travel deals.
The Challenge: Navigating a Sea of Flights
Finding the perfect multi-city trip often feels like searching for a needle in a haystack. With thousands of airports and millions of daily flights, the number of possible combinations for a multi-leg adventure is truly astronomical. A traditional search—checking every single possible combination—would take years of processing time.
To solve this, we built the Hot Picks Generator: a high-performance engine designed to surface the absolute best travel itineraries in seconds. Here’s a friendly look under the hood at the algorithm that helps you find your next great trip.
A Hybrid Approach: Python for Orchestration, C++ for Speed
When it comes to flight search, performance is everything. Our system is built as a hybrid:
- Python Layer: Handles the high-level orchestration, database connections, and messaging.
- C++ Core: The heavy lifting is done by a specialized C++ algorithm using parallel processing for massive throughput.
By shifting the core graph traversal to C++, we can process millions of flight edges per second. This allows us to explore deep into the flight graph, evaluating vast numbers of flights to find closed-loop paths that start and end at your home airport.
The Core: A Greedy Recursive Search
The engine uses a Greedy Recursive Search with heuristic pruning. Instead of exploring every possible connection, the algorithm makes smart decisions at each step to keep the search space manageable:
1. Heuristic Flight Selection
At every destination, we don't look at all outgoing flights. Instead, we score candidate flights based on cost and connectivity, only following the most promising branches. This allows us to search deep into potential trips without a combinatorial explosion.
2. Return Potential Lookahead
A great multi-city trip is only great if you can get home affordably. Our algorithm uses a "lookahead" heuristic: when choosing your next destination, it checks the Return Potential—the lowest known cost to fly back to your origin from that city. If a destination is generally expensive to return from, the algorithm deprioritizes it early.
3. Connectivity Awareness
We prioritize airports that act as hubs. If an airport has extensive cheap connections, it’s a better candidate for a multi-city stop than a small regional airport, as it increases the chances of finding high-quality subsequent legs.
The Scoring Formula: What Makes a "Hot Pick"?
Every valid closed-loop trip is assigned a final score. While price is the primary driver, we use a weighted formula to balance different priorities:
- Price: This is the dominant factor. We calculate a cost score based on both total price and cost-per-day, ensuring that the most affordable gems rise to the top.
- Global Discovery Bonus: We reward trips that visit new destinations. Interestingly, this is tracked globally during a search run using high-speed bitsets. The first trip to "discover" a new country or region in a search run gets a variability bonus, ensuring our top picks represent a wide range of geography.
- Stay Quality: The algorithm filters for stays within your preferred range but also gives a slight scoring edge to longer stays to ensure you have enough time to actually explore each city.
- Trip Complexity: More ambitious itineraries involving multiple flights receive a boost to reward the value of a comprehensive multi-city adventure.
Avoiding "Deal Clusters" with Temporal Bucketing
One common problem in travel search is that all the best deals often cluster around the same dates. To ensure our Hot Picks are useful year-round, we use Temporal Bucketing.
We divide the calendar into weekly segments. The algorithm ensures we find the best trips for every week. Once a particular week has enough high-quality trips, the algorithm uses Saturation Pruning to stop searching that period and move its processing power to other parts of the year.
Why It Matters
By combining raw processing power with human-centric heuristics, we can find hidden gems that manual searching would almost never uncover—like a multi-city trip across Europe for exceptionally low prices that balances ideal stay durations with incredible destination variety.
The Hot Picks algorithm isn't just about finding the cheapest flights; it's about engineering the perfect adventure.



