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)

    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)

    Along the garden-wall the bees
    With hairy bellies pass between
    The staminate and pistillate,
    Blest office of the epicene.
    —T.S. (Thomas Stearns)

    We are little airy creatures,
    All of different voice and features:
    One of us in glass is set,
    One of us you’ll find in jet,
    T’other you may see in tin,
    And the fourth a box within;
    If the fifth you should pursue,
    It can never fly from you.
    Jonathan Swift (1667–1745)

    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)