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)

    My business is stanching blood and feeding fainting men; my post the open field between the bullet and the hospital. I sometimes discuss the application of a compress or a wisp of hay under a broken limb, but not the bearing and merits of a political movement. I make gruel—not speeches; I write letters home for wounded soldiers, not political addresses.
    Clara Barton (1821–1912)

    No people is wholly civilized where a distinction is drawn between stealing an office and stealing a purse.
    Theodore Roosevelt (1858–1919)

    I hate love. Hate being in love. I never want it to happen to me again.
    —Muriel Box (b. 1905)

    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)