In a social network application, you need to find the shortest path between two users based on mutual friends. Would BFS be suitable for this task, or would another algorithm be more appropriate?

  • A* Algorithm
  • Breadth-First Search (BFS)
  • Depth-First Search (DFS)
  • Dijkstra's Algorithm
BFS would be suitable for finding the shortest path based on mutual friends in a social network. BFS explores neighbors first, making it effective for finding mutual connections. Other algorithms like DFS may not guarantee the shortest path and Dijkstra's Algorithm is more suitable for weighted graphs, which may not be relevant in a social network context.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *