next up previous
Next: The class ListNode Up: Unit 12 Previous: Dynamic memory management

Linked lists

A very flexible mechanism for dynamic memory management is provided by linked structures, which are realized in such a way as to allow an easy insertion and deletion of elements in specific positions, and, more generally, an easy modification of their structure.

In this course, we deal only with linear linked structures, called also linked lists, or simply lists. Such structures allow us to store collections of elements organized in the form of a linear sequence of nodes. The fact that a sequence is linear means that each element has at most one successor element (possibly none, if the element is the last one in the sequence).

Note that, in general, the number of nodes of a list is not known in advance, and we do not have variables containing references to all nodes. Instead we maintain only a reference to the first node of the list, and access the whole list through its first node, by following the links.

Hence:


next up previous
Next: The class ListNode Up: Unit 12 Previous: Dynamic memory management