21.4 Linked Lists
A linked list is a linear collection (i.e., a sequence) of self-referential-class objects, called nodes, connected by reference links—hence, the term “linked” list. Typically, a program accesses a linked list via a reference to its first node. The program accesses each subsequent node via the link reference stored in the previous node. By convention, the link reference in the last node of the list is set to null to indicate “end of list.” Data is stored in and removed from linked lists dynamically—the program creates and deletes nodes as necessary. Stacks and queues are also linear data structures and, as we’ll see, are constrained versions of linked lists. Trees are nonlinear data structures.
Lists of data can be stored in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access