Linked list: Difference between revisions
m (Replaced encyclopedic tag) |
m (Added wikipedia-style bolding and data structures link) |
||
Line 1: | Line 1: | ||
[[Category:Encyclopedia]]A linked list is a data structure which allows a great deal of flexibility in memory allocation and data sorting. |
[[Category:Encyclopedia]][[Category:Data Structures]]A '''linked list''' is a data structure which allows a great deal of flexibility in memory allocation and data sorting. Linked lists depend on [[reference|references]] for their organization. Information is stored in "nodes" which contain data (integers, strings, etc., sometimes called an "element") and one or more "links" to to other nodes. The number of links determines what type of linked list it is (one link: "singly-linked list", two links: "doubly-linked list", three links: "triply-linked list", etc.), though one or two links are most common. Linked lists have a "head" (the first node in the list) and sometimes a "tail" (the last node). |
||
Here are examples of the two common types of linked lists: |
Here are examples of the two common types of linked lists: |
||
Line 5: | Line 5: | ||
==Singly-Linked List== |
==Singly-Linked List== |
||
A singly-linked list allows traversal in one direction, forward. |
A singly-linked list allows traversal in one direction, forward. To this end, each data element contains a reference to the next data element in the sequence. |
||
===See also=== |
===See also=== |
||
Line 16: | Line 16: | ||
==Doubly-Linked List== |
==Doubly-Linked List== |
||
A doubly-linked list allows traversal in two directions, forward and back. |
A doubly-linked list allows traversal in two directions, forward and back. To this end, each data element contains references to both the previous and next elements. |
||
===See also=== |
===See also=== |
Revision as of 14:18, 28 February 2008
A linked list is a data structure which allows a great deal of flexibility in memory allocation and data sorting. Linked lists depend on references for their organization. Information is stored in "nodes" which contain data (integers, strings, etc., sometimes called an "element") and one or more "links" to to other nodes. The number of links determines what type of linked list it is (one link: "singly-linked list", two links: "doubly-linked list", three links: "triply-linked list", etc.), though one or two links are most common. Linked lists have a "head" (the first node in the list) and sometimes a "tail" (the last node).
Here are examples of the two common types of linked lists:
Singly-Linked List
A singly-linked list allows traversal in one direction, forward. To this end, each data element contains a reference to the next data element in the sequence.
See also
- Singly-Linked List (element)
- Singly-Linked List (element insertion)
- Singly-Linked List (element removal)
- Singly-Linked List (traversal)
Doubly-Linked List
A doubly-linked list allows traversal in two directions, forward and back. To this end, each data element contains references to both the previous and next elements.