[CareerCup] 10.2 Data Structures for Large Social Network 大型社交网站的数据结构 - Grandyang - 博客园
[CareerCup] 10.2 Data Structures for Large Social Network 大型社交网站的数据结构
10.2 How would you design the data structures for a very large social network like Facebook or Linkedln? Describe how you would design an algorithm to show the connection, or path, between two people (e.g., Me -> Bob -> Susan -> Jason -> You).
这道题让我们实现大型社交网站的数据结构,首先用户类Person需要包含好友和其他的一些信息,而且大型网站一般可能会有上百万的用户,我们一般不可能把所有的数据都存在一台机器上,所以我们在查找好友时,需要先查找好友所在的机器,再在机器上查询好友,每个好友或机器都有自己的编号,为了快速查找,均使用了哈希表来建立映射,参见代码如下:
Read full article from [CareerCup] 10.2 Data Structures for Large Social Network 大型社交网站的数据结构 - Grandyang - 博客园
No comments:
Post a Comment