8.4 Lists

Lists occur as naturally in programming as they do in real life. We manipulate guest lists, grocery lists, class lists, and things-to-do lists. The list of lists is endless. Three properties characterize lists: The items are homogeneous, the items are linear, and lists have varying lengths. By linear, we mean that each item except the first has a unique component that comes before it, and  each item except the last has a unique component that comes after it. For example, if there are at least three items in a list, the second item comes after the first and before the third.

Whereas stacks and queues have all the semantics in the deletion operation, lists usually provide operations to insert an item (Insert), delete an item (Delete ...

Get Computer Science Illuminated, 7th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.