recursion - What makes a data structure recursive? -


i reading recursive data type has following quote:

in computer programming languages, recursive data type (also known recursively-defined, inductively-defined or inductive data type) data type values may contain other values of same type

i understand linked list , trees can recursive data type because contains smaller version of same data structure, tree can have subtree.

however, go me confused because isn't fixed size array contains sub-array? still same type?

can explain examples makes data structure recursive?

however, go me confused because isn't fixed size array contains sub-array?

conceptually, every array "contains" sub-arrays, arrays aren't made of smaller arrays in code. array made of continuous chunk of elements, not other arrays.

in pseudocode, recursive structure (like, mentioned, linked list), literally has ability contain versions of itself:

class node {     node head = null; // <-- nodes can literally hold other nodes } 

whereas, if think of array it's represented in language javascript, contains elements, not other arrays:

class array<e> {    e elem1 = ...; // <-- in code, array isn't made of other arrays,    e elem2 = ...; //      it's made of elements.     ... } 

a structure recursive if while navigating through it, come across "smaller" versions of whole structure. while navigating through array, you'll come across elements array holds, not smaller arrays.

note though, depends entirely on implementation of structure. in clojure example, "vectors" behave identical arrays, , can thought of arrays while using them, internally, they're tree (which i'm guessing recursive).


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -