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


Please Help Members By Posting Answers For Below Questions

Why does this code crash?

610


Explain what is the difference between functions getch() and getche()?

601


Define recursion in c.

693


Can you subtract pointers from each other? Why would you?

554


Can we access the array using a pointer in c language?

554






What is bash c?

550


How can you return multiple values from a function?

626


What is volatile keyword in c?

577


Can math operations be performed on a void pointer?

581


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1444


Why clrscr is used in c?

575


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); } }

1953


What does dm mean sexually?

806


What are the header files used in c language?

578


What is structure in c definition?

568