Linked List - Basic Concepts and Nomenclature - Post Office Box Analogy

Post Office Box Analogy

The concept of a linked list can be explained by a simple analogy to real-world post office boxes. Suppose Alice is a spy who wishes to give a codebook to Bob by putting it in a post office box and then giving him the key. However, the book is too thick to fit in a single post office box, so instead she divides the book into two halves and purchases two post office boxes. In the first box, she puts the first half of the book and a key to the second box, and in the second box she puts the second half of the book. She then gives Bob a key to the first box. No matter how large the book is, this scheme can be extended to any number of boxes by always putting the key to the next box in the previous box.

In this analogy, the boxes correspond to elements or nodes, the keys correspond to pointers, and the book itself is the data. The key given to Bob is the head pointer, while those stored in the boxes are next pointers. The scheme as described above is a singly linked list (see below).

Read more about this topic:  Linked List, Basic Concepts and Nomenclature

Famous quotes containing the words post, office, box and/or analogy:

    “I had rather be shut up in a very modest cottage, with my books, my family and a few old friends, dining on simple bacon, and letting the world roll on as it liked, than to occupy the most splendid post which any human power can give.”
    —Thomas Jefferson (1743–1826)

    “Just across the Green from the post office is the county jail, seldom occupied except by some backwoodsman who has been intemperate; the courthouse is under the same roof. The dog warden usually basks in the sunlight near the harness store or the post office, his golden badge polished bright.”
    —Administration for the State of Con, U.S. public relief program (1935-1943)

    “I have simply ordered a box of maniacs.
    They can be sent back.
    They can die, I need feed them nothing, I am the owner.”
    —Sylvia Plath (1932–1963)

    “The whole of natural theology ... resolves itself into one simple, though somewhat ambiguous proposition, That the cause or causes of order in the universe probably bear some remote analogy to human intelligence.”
    —David Hume (1711–1776)