How are linked lists executed without using a pointer?

It's easy to implement a linked list in C ++, where you have pointers. But how are they implemented in other languages ​​(e.g. java, python, etc.). I do not want to use the built-in class (which is supported by JAVA) for the linked list, but I want how to replace pointers to create a linked list?

+5
source share
7 answers

They are implemented using references, which are essentially (excluding syntactic) pointers that you cannot execute using pointer arithmetic (in some languages ​​they cannot be empty either). In many languages, references are the standard way to use variables, unlike C ++, where the default value is a value.

+26

, .

+5

, , , . , ++

Struct Node {
  Node *last;
  Node *next;
}

:

Struct Node {
  Node last;
  Node next;
  }
+2

, class node, node node, node ( null, )

0

, , FORTRAN.

. .

, , .

0

- http://www.amazon.com/Introduction-Algorithms-Thomas-H-Cormen/dp/0262033844 - , .

(, n, n = , ). Array A Array B.

A [i] . Array B [i] "" k, , A [i] → next = A [k].

, .

0

, , . , .

++, , , . , .

. , . , , , .

. , . .

The basic concept for linked lists is not pointers, it is that the items in the list are responsible for tracking the item associated with it.

0
source

All Articles