4 ms·
Thanks for the reply. I will definitely look into your suggestion, because if it's the optimal solution, I want it to be the first one I think of. Even though
by nopal 16y ago
Thanks for the reply.
I will definitely look into your suggestion, because if it's the optimal solution, I want it to be the first one I think of. Even though these types of problems don't come up for me that often, I'm sure there are times where a textbook CS solution would have been the best solution.
- k4st 16y agoIt depends on exactly what you're trying to optimize and what the requirements are. While it's not necessarily the best solution for a Facebook style problem (where you actually want to aggregate the results, where other concerns would be pagination of said results, permissions, etc.), an interesting algorithm to look at when you want to traverse a graph up to a certain depth looking for some specific "target" is iterative deepening. In basic terms, it is a depth-first search up to depth N inside a loop that increments N on each iteration.