在数据库驱动的网站中使用图形、树和其他高级数据结构的一些示例有哪些?
那么什么时候 LAMP 堆栈中的简单 $array()
变量还不够呢?我确信这些高级数据结构很有用,但我想知道是否有人可以建议在网络环境中的一些用途,特别是在社交网络和类似的数据驱动网站中通常将它们用于什么目的?
So when are simple $array()
variables in your LAMP stack not enough? I'm sure these advanced data structures are useful but I'm wondering if someone can suggest some uses in a web context especially what one typically uses them for in social networking and similar data driven sites?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是,在任何足够复杂的系统(网络或非网络)中,不同的数据集在不同的时间以不同的方式使用,并且数据的使用方式决定了所使用的结构。例如,树查找内容的速度很快,因为二分搜索非常有效,并且根据结构,插入也可以很快,而链表插入/删除速度很快,但会跳转到特定点(根据二分搜索的需要)非常慢,因为你必须遍历列表。另一方面,数组列表的搜索速度要快得多,但插入/删除可能非常慢。
因此,简而言之,所使用的结构主要取决于所访问数据的性能需求,无论平台如何。
The answer is that, in any sufficiently complex system (web or not), different sets of data are used in different ways and at different times, and how the data is going to be used dictates the structure that is used. Trees, for example, are fast for looking things up in because a binary search is very efficient, and depending on the structure can also be fast at inserting, whereas a linked list is fast to insert/remove, but jumping to a particular point (as needed in a binary search) is very slow because you have to walk the list. On the flip-side, an array list is much faster at searching, but insert / delete can be very slow.
So, in a nutshell, the structures used primarily depend on the performance needs of the data being accessed, regardless of platform.
简短的回答:树可以用于任何具有明确“父母”的实体的情况。例如,假设您有一个仅限邀请的社交网络。在这种情况下,您可以将用户构建为树,每个用户数据库条目中都有一个“父”条目。
抱歉,如果我误解了你的问题,但它非常模糊。对于使用树的变量的情况,请考虑我们可能会迭代上例中的数据库,并根据现有用户构造一棵树来执行某种操作。
Short answer: a tree might be used in any situation where there are entities which have clear 'parents'. For example, let's say you have an invite-only social network. In this case you might structure the users as a tree, with a 'parent' entry in each user database entry.
Sorry if I've misunderstood your question, but it's awfully vague. For cases of variables using trees, consider that we might iterate through the database in the above example and construct a tree out of the existing users to perform actions of some sort.