Linked list
A linked list is a structure that collects multiple data like an array, but the order
of the data is not always a continuous area of memory. The pointer points to
the next data storage location. There are the following types of linked lists:
(1)Singly-linked list
A singly-linked list is a list in which pointers are concatenated in only one
direction. In the figure below, the route represents the start position and
follows the address pointed to by the pointer. In case of this list, you can
search the data only in the order of "A→B→C".
If you want to add data to the list, you change the value of the pointer. In the
figure below, the pointer of B is changed to 30, and the pointer of Z is changed
to 32. By doing this, you can search the data in the order of "A→B→Z→C".
(2)Doubly-linked list
A doubly-linked list is a list that enables searching the data from both
directions with two pointers. In case of this list, you can search the data not
only in the order of "A→B→C" but also in the order of "C→B→A".
(3)Circularly-linked list
A circularly-linked list is a list that enables searching the data from the
beginning again by storing the storage location of the first data in the pointer
of the data at the end of the list.
[Japanese]
連結リスト
連結リストは、配列のように複数のデータを集めた構造ですが、データの順番がメモリの連続した領域とは限らないものです。ポインタと呼ばれるものによって、次のデータの格納場所を指し示します。連結リストには、次の種類が
あります。
(1)片方向リスト
片方向リストは、一つの方向だけポインタを連結したリストです。
下図でルートは開始位置を表しており、ポインタが指し示すアドレスを辿っていきます。下図の片方向リストであれば「A→B→C」の順番でのみ探索が可能です。
もしリストにデータを追加したい場合は、ポインタの値を変えます。
下図では、Bのポインタを30に変え、Zのポインタを32にしてCを指すようにしています。こうすることで、「A→B→Z→C」の順番で探索できます。
(2)双方向リスト
双方向リストは、2つのポインタにより、両方向からの探索を可能にしたリストです。下図の双方向リストであれば「A→B→C」の順番だけでなく、
「C→B→A」の順番でも探索が可能です。
(3)循環リスト
循環リストは、リストの末尾のデータのポインタに先頭のデータの格納場所を格納することで、再び先頭からの探索を可能にしたリストです。