在我的算法类中,我被告知用于图表表示的邻接列表的缺点是迭代通过对应于每个节点的相邻节点阵列的O(n)查找时间.我通过使用HashMap实现我的邻接列表,HashMap将节点映射到它们相邻节点的HashSet,这不是只需要O(1)查找时间吗?有什么我想念的吗?
algorithm big-o graph hashmap adjacency-list
adjacency-list ×1
algorithm ×1
big-o ×1
graph ×1
hashmap ×1