DEA-C01 Question 139
Single answerA social media platform is using Amazon Neptune to store and analyze its user relationships. The platform needs to find the shortest path between two users to recommend connections. Which data structure and algorithm combination would be most appropriate to solve this problem in Amazon Neptune?
- A
Graph data structure with Dijkstra's algorithm
- B
Tree data structure with Depth-First Search (DFS)
- C
Graph data structure with Breadth-First Search (BFS)
- D
Tree data structure with Binary Search
Show answer and explanation
Correct answer: A
Explanation
The problem involves finding the shortest path between two users in a social media network, which is best represented as a graph. Amazon Neptune is optimized for graph queries, and Dijkstra's algorithm is a well-suited algorithm for finding the shortest path in a weighted graph. Other options either use inappropriate data structures or algorithms that do not solve the problem effectively.
- A. Correct.
Correct. Graph data structures are ideal for representing relationships or connections, and Dijkstra's algorithm is widely used to find the shortest path between nodes in a graph. Amazon Neptune supports graph queries that can utilize such algorithms.
- B. Incorrect.
Incorrect. A tree data structure is not suitable for representing all user relationships in a social media network since a tree imposes a hierarchical structure without cycles, unlike a graph.
- C. Incorrect.
Incorrect. While BFS can find the shortest path in an unweighted graph, it is not optimal for weighted graphs, which is a common scenario in real-world applications. Dijkstra's algorithm is better suited for weighted graphs.
- D. Incorrect.
Incorrect. Binary Search is used for searching in sorted datasets, and a tree data structure does not support arbitrary relationships between users like a graph does.