What is real life example of linked list

Thread Starter

Parth786

Joined Jun 19, 2017
642
Simply a list is a sequence of data, and linked list is a sequence of data linked with each other. linked list is a sequence of elements in which every element is linked to its next element.

In terms of programming
upload_2017-11-7_19-24-49.png


I found real life example of linked list is a Train, here each coach is connected to its previous and next coach (Except first and last).

I am looking real example more then the definition. What is real of example for linked list? What is a real life situation where a single linked list can be used in programming ?
 

spinnaker

Joined Oct 29, 2009
7,830
What does this question have to do with embedded systems and micro controllers???

If you have the definition then you have the example.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
What does this question have to do with embedded systems and micro controllers???

If you have the definition then you have the example.
Sorry for wrong section . I think it should be in general electronics chat or programming section but I thought its related to microconreoller and programming. I think linked list use in embedded programming


My purpose is to understand the basic of linked list in programming but the reality is that I don't understand situation where a single linked list can be used in c and embedded C programming ? I was looking some real life example for linked list

Note : I am not asking for program. I am just looking for example's. I have seen some example like I have mentioned example of train and
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
Successive clues in a Treasure Hunt game?
HTML hyperlinks?
A list of names.
A list of inventory items.
List of dates


There are thousands maybe millions of places where you might use a linked list.

Using a linked list as opposed to say just an array of pointers is the programmers decision.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
There are thousands maybe millions of places where you might use a linked list.
For your quick response I have created this chart for linked list

upload_2017-11-7_21-9-17.png
Do I need to add extra information in diagram to understand basic of linked list ? What is benefits of liked list in above situation ?
 

WBahn

Joined Mar 31, 2012
29,979
Linked lists are used in an endless number of situations. It is one of the more fundamental data structures used to construct more complex data structures.

Many programming language implementations used some type of a linked list to keep track of memory blocks that are dynamically allocated.

One of the common drivers for using a linked list is when you don't know either the number or the size of each of the elements of a set that you need to keep track of. If you know both of those, then using an array is a viable option. But when you need to add and remove elements on the fly or when the elements vary in size, this is not as clean an option.

Linked lists are pretty memory efficient in that there is only a small amount of overhead for the links per item, but traversing the data set can be very time intensive depending on what you are trying to do. So, like everything, there are tradeoffs that have to be considered when making your decision.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
Linked lists are used in an endless number of situations. It is one of the more fundamental data structures used to construct more complex data structures.
.
Now I am getting some point on linked list. What could be example of linked list in embedded programming. I have search on internet and visited two or three pages https://www.google.co.in/search?q=l...EcXbvgTmgqGYAQ&start=10&sa=N&biw=1366&bih=659

Its quite difficult to get simple example What could be simple example of linked list in embedded system to understand basics ?
 
Last edited:

WBahn

Joined Mar 31, 2012
29,979
If your embedded system uses any kind of dynamically allocated memory, then the memory manager probably uses a linked list to manage the memory. Each block of memory keeps track of its size and, if it is available, has a link to the next block of available memory. As memory is allocated and deallocated, the links are traversed and updated.

If you want to get a good overview of how a simple computer works from top to bottom, then an excellent project is the Nand2Tetris project. I've recommended this to you before, but see no indication that you have even attempted to explore it. Instead, as usual, you want people to explain everything to you in a hodgepodge fashion. And, as expected and has been observed by several members, there is little evidence that this is getting you anywhere.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
If you want to get a good overview of how a simple computer works from top to bottom, then an excellent project is the Nand2Tetris project. I've recommended this to you before, but see no indication that you have even attempted to explore it. Instead, as usual, you want people to explain everything to you in a hodgepodge fashion. And, as expected and has been observed by several members, there is little evidence that this is getting you anywhere.
Learning about computer work from top to bottom is very difficult task. I think it takes a lot of time to become good. I am following Nand2Tetris project.

I have made slight changes in myself. I want to focus only on one topics at one time. There are still some question in my mind. I have not asked it. Right now my purpose was to find out some simple example of linked list for C and embedded c programming.

Now In this thread I have not given attention to programming. Neither I have asked about program. I was just looking for simple examples

I have find out example in C programming. As I said I did google and visited some pages but I did not get simple example of linked list in embedded system. There are some example I have seen which are going above my head.
 
Last edited:

eetech00

Joined Jun 8, 2013
3,859
Generally speaking, linked lists are data structures created by dynamically allocating memory. They can also be dynamically released.
Memory data elements are accessed via a “pointer” to the element of interest. Once memory is released, it can be used for other purposes.

The alternative is to statically allocate memory in the form of variable declaration statements. The problem with this is once declared, the allocated memory is never released. It remains allocated until the program is terminated.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
A good example helps a lot in understanding basic. That's why I am looking example of linked list in real life for embedded system. thought so much, what i make in embedded system to learn the use of linked list. Can anyone tell me example in embedded system in which only linked list will use. any example, where only linked list will use ?. I looked on google but I didn't get much help from it.
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
A good example helps a lot in understanding basic. That's why I am looking example of linked list in real life. Can anyone tell me example in embedded system in which only linked list will use. any example, where only linked list will use ?. I looked on google but I didn't get much help from it.

You have been given a couple of examples already. This is not that difficult of a concept.

Another example. You are sampling voltages or events with a mcu. You don't know how many youare going to sample so you use a linked list.
 

panic mode

Joined Oct 10, 2011
2,715
it is just a LIST - a a way of keeping track of information. on many platforms arrays are quite rigid and don't allow resizing. this poses a problem in many ways - you must plan how big array to declare. if you end up using none or just few elements only, you just wasted big chunk of memory that could be very useful for something else. if you declare array as smaller one, you may hit the limit as soon as few elements are added. list can be endless and change size dynamically.


it is like deciding what vehicle to buy if you only can have one.

bicycle is great for short commute but you cant really have passengers.
motorcycle usually allows for one passenger and it can travel faster and therefore greater distances but it is not good for cargo.
you may buy a car and it is a next step upgrade.
you may choose to buy a van, plenty more space, can bring entire entourage or help your girlfriend move.
so you have to think long and hard what to choose.... and you know that once yu make choice, that's pretty much it.... you cannot have motorcycle one day, van the next day, etc. once you commit you are pretty much stuck.

now imagine if there was some magic vehicle that you can configure by press of a button to be different size. you want to go to library to return single book, dial it down to a small size. heck once you arrive if there is no parking space, shrink it down to a credit card and stick it into your back pocket - parking problem solved.
but if you want to go on a cross country trip with 20 gold diggers, you simply dial supersize feature with casino, swimming pool, balcony and helipad (and whatever your heart desires and credit limit can afford) - problem solved. and the best of all is that every time you go for a drive, you can have the right size... would not that be amazing?

that is flexibility that list allows you to have - scalability .
 
Last edited:

Thread Starter

Parth786

Joined Jun 19, 2017
642
You have been given a couple of examples already. This is not that difficult of a concept.

Another example. You are sampling voltages or events with a mcu. You don't know how many youare going to sample so you use a linked list.
IR sensor become active when It detect target and it will become deactivate when there is no target. We don't know how many time it activate and deactivate. Is it example of linked list ? Can we write linked list program for this situation?.
 
Last edited:

spinnaker

Joined Oct 29, 2009
7,830
IR sensor become active when It detect target and it will become deactivate when there is no target. We don't know how many time it activate and deactivate. Is it example of linked list ? Can we write linked list program for this situation?.

If you wanted to keep track of the time and date or some other data when the IR sensor was tripped then yes you could use a linked list. If it is just an IR event then there really would not be a reason for a linked list.
 

WBahn

Joined Mar 31, 2012
29,979
A good example helps a lot in understanding basic. That's why I am looking example of linked list in real life for embedded system. thought so much, what i make in embedded system to learn the use of linked list. Can anyone tell me example in embedded system in which only linked list will use. any example, where only linked list will use ?. I looked on google but I didn't get much help from it.
You've already been given a few examples.

Any time you want a stack-like data structure, a singly-linked list is potentially a good fit. This is because a (pure) stack only operates at one end of the list and so there is never any need to traverse the list. Traversing linked lists is bad (unless what you are doing specifically involves doing something which each element of the list in order).
 

WBahn

Joined Mar 31, 2012
29,979
IR sensor become active when It detect target and it will become deactivate when there is no target. We don't know how many time it activate and deactivate. Is it example of linked list ? Can we write linked list program for this situation?.
That's not an example of a linked list. It's merely an example of a certain kind of data you want to work with.

Yes, you can write a linked list program to work with that data, but whether it is reasonable to do so depends on how you want to interact with the data.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
That's not an example of a linked list. It's merely an example of a certain kind of data you want to work with.

Yes, you can write a linked list program to work with that data, but whether it is reasonable to do so depends on how you want to interact with the data.
All of you have given many examples but still I have problem to understanding the linked list with example in embedded system. I have been searching a lot on internet . Can you prepare problem statement for that example because i couldn't make one example after my many effort . can you give any problem statement that suit for linked list in embedded system.
 
Last edited:
Top