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.
Thanks.
Self-referencing lists, and, generally speaking, circular data structures, can be caused when representing a graph using data structures.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With