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, post, office, box and/or analogy:

    A demanding stranger arrived one morning in a small town and asked a boy on the sidewalk of the main street, “Boy, where’s the post office?”
    “I don’t know.”
    “Well, then, where might the drugstore be?”
    “I don’t know.”
    “How about a good cheap hotel?”
    “I don’t know.”
    “Say, boy, you don’t know much, do you?”
    “No, sir, I sure don’t. But I ain’t lost.”
    William Harmon (b. 1938)

    Fear death?—to feel the fog in my throat,
    The mist in my face,
    When the snows begin, and the blasts denote
    I am nearing the place,
    The power of the night, the press of the storm,
    The post of the foe;
    Where he stands, the Arch Fear in a visible form,
    Yet the strong man must go:
    Robert Browning (1812–1889)

    The dissident does not operate in the realm of genuine power at all. He is not seeking power. He has no desire for office and does not gather votes. He does not attempt to charm the public, he offers nothing and promises nothing. He can offer, if anything, only his own skin—and he offers it solely because he has no other way of affirming the truth he stands for. His actions simply articulate his dignity as a citizen, regardless of the cost.
    Václav Havel (b. 1936)

    He had put, within his reach,
    A box of counters and a red-veined stone,
    A piece of glass abraded by the beach,
    And six or seven shells,
    A bottle with bluebells,
    And two French copper coins, ranged there with careful art,
    Coventry Kersey Dighton Patmore (1823–1896)

    The analogy between the mind and a computer fails for many reasons. The brain is constructed by principles that assure diversity and degeneracy. Unlike a computer, it has no replicative memory. It is historical and value driven. It forms categories by internal criteria and by constraints acting at many scales, not by means of a syntactically constructed program. The world with which the brain interacts is not unequivocally made up of classical categories.
    Gerald M. Edelman (b. 1928)