I understand the definition of a Linked List, but how can it be represented and related to a common concept or item?
For example, composition (EDIT: originally said 'inheritance') in OOP can be related to automobiles. All (most) automobiles in real life are the essentially same thing; an automobile has an Engine, you can start() it, you can make the car go(), stop() and so on. An automobile would typically have a maximum passenger capacity but it would differ between a Bus and a SportsCar, which are both automobiles.
Is there some real life, intuitive example of the plain ole' singly Linked List like we have with inheritance? The typical textbook Linked List example shows a node with an integer and a pointer to the next, and it just doesn't seem very useful.
Your input is appreciated.
Giving travel directions: With each step in the directions being a node, and the travel instruction between each node as your link.
Example:
Node 1: Start at Home
Link: Walk 3 blocks South to Bob's House
Node 2: Bob's house
Link: Walk 2 blocks North to Alice's House.
Node 3: Alice's house
If you want to get one place to another you have to follow the links(instructions) from each intermediate place(node), you can't just skip from home to Alice's.
Look at Linked List as a data structure. It's mechanism to represent self-aggregation in OOD. And you may think of it as real world object (for some people it is reality)
Waiting line at a teller/cashier, etc...
A series of orders which must be executed in order.
Any FIFO structure can be implemented as a linked list.
Inside the
make
program, you will often find that the dependency lists for a particular file that needs to be built are defined as linked lists of pointers to other files which also need to be built and in turn have dependencies in linked lists.In operating systems ... one may use a linked list to keep track of what processes are running and what processes are sleeping ... a process that is running and wants to sleep ... gets removed from the LinkedList that keeps track of running processes and once the sleep time is over adds it back to the active process LinkedList
Maybe newer OS are using some funky data structures ... linked lists can be used there
He did ask for a practical example; so I'll give it a shot:
Lets say you are writing a firewall; in this firewall you have an IP whitelist and an IP blacklist.
You know that your IP, your jobs IP, and some testing IP's need to be whitelisted. So, you add all of the IP's to the whitelist.
Now, you also have a list of known IP's that should be blocked. So, you add those IPs to the blacklist.
Why might use LinkedList for this?