patternMinor
Is there any practical application for arrays that contain themselves?
Viewed 0 times
arraysapplicationcontainanythatforpracticaltherethemselves
Problem
I'm reading the introduction to Godel, Escher, Bach and and there's heavy discussion of mathematical sets which contain themselves. Being a far better programmer than mathematician, I put it into terms I'm more comfortable with and started to think about arrays which contain/reference themselves.
I know that recursion is a very powerful concept in CS but that it's typically manifested through functions which call themselves. I see recursive functions in algorithms all the time, but I've never before run across an array that has itself as an element. I was just wondering if there's any particular "usefulness" or practical application for arrays which contain themselves (as there is for functions which call themselves).
I know that recursion is a very powerful concept in CS but that it's typically manifested through functions which call themselves. I see recursive functions in algorithms all the time, but I've never before run across an array that has itself as an element. I was just wondering if there's any particular "usefulness" or practical application for arrays which contain themselves (as there is for functions which call themselves).
Solution
If you represent a (directed) graph in an adjacency "list" representation, i.e. each node has an array of (pointers to) its immediate successors, then any cyclic graph would arguably be an example of an array that "contains" (really references) itself. In practice, the "object graph" of references between the objects in a program will often be an example of this albeit not quite so cleanly
Indeed, for non-well-founded set theories with an anti-foundation axioms stating that sets can contain themselves, cyclic graph models are quite natural.
Indeed, for non-well-founded set theories with an anti-foundation axioms stating that sets can contain themselves, cyclic graph models are quite natural.
Context
StackExchange Computer Science Q#86283, answer score: 4
Revisions (0)
No revisions yet.