The wikipedia articles are too advanced for me to understand, could someone give me a simple explanation please?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
The context of the two terms is generally different.
Self referencing is in the context of data -- you have a data type that contains a reference to something of the same type.
Rerusive is in the context of code -- you have a function or procedure that calls itself.
Here's a recursive function (in C):
Those two calls to
Here's a self-referential data structure:
The first element,
Now you've got a different kind of self-reference -- it's not just the definition of
Recursions, mostly useful ones, are expected to terminate after certain number of procedures in a sense that there is some initial value. unless you have a bad recursion that is useless.
Self References, are by themselves not exactly recursions but can be shown to have recursion in which case they generally never terminate.
Recursion implies action.
Technically, recursion should have an exit state but it's not a requirement.
Self-reference implies structure.
Ex. An instance method referencing the object it's attached to.
Recursion requires something to process via calling the same process (often with different parameters). Even though you're often using functions and those functions call themselves, they technically enter a new step that just happens to look like the place they just came from.
Self-Reference means that something refers to itself. Classes can be self-referential by using