what is the difference between arrays and linked list
Answer Posted / durairaj
Arrays
Strengths
1.Easy to use
2.No memory management needed
3.Can access any element by index
4.Fairly quick to loop
Weaknesses
1.Static size (can’t increase the size)
2.Most likely not enough or too much memory (you never know
how many elements are needed)
Linked Lists
Strengths
1.Dynamic size (can increase or decrease the list)
2.No memory is wasted
Weaknesses
1.Lots of overhead code (lots of malloc calls and assigning
pointers)
2.Must traverse entire list to go to the nth node.
Now I know that other languages such as C# and Java have
better data structures than arrays and linked lists (like
ArrayLists and Vectors), but this is for the C language and
it doesn’t have those. So based on what you’ve read above
you can decide which is better for the job needed. Neither
arrays nor linked lists are better but they do have their
specific purposes.
| Is This Answer Correct ? | 23 Yes | 4 No |
Post New Answer View All Answers
Where define directive used?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is the most efficient way to store flag values?
What is an auto variable in c?
Describe dynamic data structure in c programming language?
Here is a good puzzle: how do you write a program which produces its own source code as output?
What is difference between scanf and gets?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
Why is c so important?
What is the difference between fread buffer() and fwrite buffer()?
C program to find all possible outcomes of a dice?
Do you know what are bitwise shift operators in c programming?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
What is const and volatile in c?
What is use of integral promotions in c?