题目
题目

XLMC0202501 Topic 20 Quiz

单项选择题

Suppose a graph data structure is used to represent social media relationships.  Each node represents a user, and a directed edge exists between user A and user B if user A follows user B.  Let's further define a notion of influence.  We say that use A is influened by user B if there is a path of "follow" relationships from user A to user B.  So if user A follows user B, then A is influenced by user B.  If B also follows user C, then user A is also influenced by user C since there is a directed path A->B->C.    If the primary use of this graph is to query if one user is influenced by another, which graph data structure would be more efficient in terms of the time required to complete the query?

选项
A.Adjacency List
B.Adjacency Matrix
查看解析

查看解析

标准答案
Please login to view
思路分析
When evaluating reachability queries (whether A can influence B via a directed path), the choice between an adjacency list and an adjacency matrix centers on how quickly you can answer such queries. Option 1: Adjacency List. This representation is very space-efficient for sparse graphs, since you store only existing edges. However, answering a reachability query like “is there a path fro......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!