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
Why does this code crash?
Explain what is the difference between functions getch() and getche()?
Define recursion in c.
Can you subtract pointers from each other? Why would you?
Can we access the array using a pointer in c language?
What is bash c?
How can you return multiple values from a function?
What is volatile keyword in c?
Can math operations be performed on a void pointer?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Why clrscr is used in c?
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
What does dm mean sexually?
What are the header files used in c language?
What is structure in c definition?