使用的自参考名单名单

由网友(天長地久崩潰)分享简介:我知道它是可以创建自参考列表语言如Python:I know it is possible to create a self referencing list in languages like Python:>>> my_list = [1,2]>>> my_list.append(my_list)>>> p...

我知道它是可以创建自参考列表语言如Python:

I know it is possible to create a self referencing list in languages like Python:

>>> my_list = [1,2]
>>> my_list.append(my_list)
>>> print my_list
[1,2,[...]]
>>> print my_list[0]
1
>>> print my_list[2]
[1,2,[...]]

从什么自参考名单算法的好处?我不认为一个人的。

What algorithms benefit from self referencing lists? I cannot think of one.

感谢。

推荐答案

自引用列表和,一般说来,圆形的数据结构,可以使得当重新$ P $使用数据结构psenting的曲线图。

Self-referencing lists, and, generally speaking, circular data structures, can be caused when representing a graph using data structures.

例如,考虑的曲线图的此幼稚重新presentation:每个节点是一个原子值,或者说,它连接到的节点的列表。一个圆可能会导致列表以包含包含列表另一个列表。一种自圆,即,从一个节点到它本身的边缘,将导致自引用列表

For example, consider this naive representation of a graph: Each node is either an atomic value, or a list of nodes that it is linked to. A circle may cause a list to contain another list that contains the list. A self-circle, i.e., an edge from a node to itself, will cause a self-referencing list.

阅读全文

相关推荐

最新文章