Hello everyone, I am studying link list in c I have a project in which I have lookup table of rpm (clocks used to load the timer used for motor). This rpm table, I am taking in an array Now I want to implement a link list which will access the rpm from table and load it to timer of clock used for running the motor Is it possible Because as I am studying the link list, in that it is mentioned that link list is used instead of array Is it possible to access an array elements using link list ? If yes, then pls suggest me some link for it Correct me if I am wrong Thank u all
A linked-list is essentially a sequential access data structure; ie, you begin at one end of the list, and search through it until you find the desired entry.
A lookup table, on the other hand, is a direct access data structure; ie, you can go direct to the required entry simply by using its index.
"Now I want to implement a link list which will access the rpm from table ... Is it possible"
Of course it is possible - but I can't see any benefit in doing it!
There are many applications where linked-lists can be useful - but I really don't think this is one of them! Why do you think this will be beneficial? Why not just access the lookup table directly in the normal manner?
"Because as I am studying the link list, in that it is mentioned that link list is used instead of array"
Perhaps you need to study whatever source said that a bit more carefully and look at the reasons why a linked-list might be chosen instead of an array. I don't think this is one of them.
Note that this is standard 'C' - it has nothing specifically to do with Keil, C51, or the 8051
thanx for reply Andy; i know my project doesnot need any link list but to study purpose i want to implement, so that i will be familier with link list can u suggest me any link for this topic thank u again
"Note that this is standard 'C' - it has nothing specifically to do with Keil, C51, or the 8051"
Note that most textbook examples will use dynamic memory allocation (malloc, etc) to create the entries in the list. One of the key advantages of linked-lists is the way that the entries can be dynamically created like this - but that does not mean that they have to be dynamically created.
In fact, for embedded systems in general and the 8051 in particular, it is most likely that the entries should not be dynamically allocated!
In an embedded system, it is far more likely that you would statically create a fixed number of entries, and simply link them into either a "free" list or an "in-use" list.
www.8052.com/.../read.phtml
apart from the obvious disadvantage of dynamic memory allocation, you might also want to consider the cost in terms of computation cycles: O(n) in the worst case for a linked list, unless some mostly useless tricks are used (that consume CPU cycles while maintaining them) like (I am not sure I am using the correct terminology here) "jump lists", that reduce average access time to O(log(n)).
"apart from the obvious disadvantage of dynamic memory allocation"
As already noted, it is perfectly possible to use linked-lists without any use of dynamic memory allocation!
The example I cited illustrates this.
Andy, Where did I say otherwise? Of it is possible.
I meant, of course: "of course it is possible."