GeekInterview.com
Series: Subject: Topic:
Question: 412 of 828

differences between Arrays and Linked lists

What are the differences between Arrays and Linked lists and why we go for linked lists if we have pointers to arrays?
Asked by: Interview Candidate | Asked on: Nov 6th, 2006
Showing Answers 1 - 12 of 12 Answers
mahesh

Answered On : Nov 6th, 2006

Arrays cannot be expanded or increased so we use linked list for dynamic data storage

  
Login to rate this answer.
shekhar

Answered On : Nov 7th, 2006

For example::We want to delete some elements from array then either we have to place zero or we need to rearrange it.For dynamic deletion and insertion linked list is used instead arrays.But if we do not need these operations then using arrays is sufficient and easier too.

  
Login to rate this answer.
rathnam

Answered On : Nov 14th, 2006

space/time trade-off are the parameters to differentiate between them. Space:===== In the case of Arrays: for storing 10 elements, we need only 10* sizeof(element) bytes. In the case of Lists: for storing 10 elements, we need at least 10*(sizeof(element)+sizeof(int*)); so, we need more space in the case of linked lists to store the same data when compared to lists. => Arrays are better; Time:====In the case of Array indexing is possible, so it takes constant time to access a particular data item. But where as in the case of lists, random access is not possible, it takes variable amount of time to access a particular data item. => Arrays are better. Misselleneous: ===========1) Some data structures can be represented easily with linked lists when compared to arrays. 2) Addition and Deletion is easier in the case of lists. 3) making a copy is easier in the case of Arrays because the memory is contigeous.

  
Login to rate this answer.
Manoj

Answered On : Dec 27th, 2006

Arrays and Linked list both are list data structures used for maintaining a list of values. Arrays use sequential allocation while Linked list uses linked allocation. > Linked list uses some extra memory i.e. link pointer. > Indexing an element, e.g. accessing kth element is cheaper in arrays and costly in Linked list.> Insertion and Deletion of elements is a cheaper operation in Linked lists.> Since nodes in Linked list are dynamically allocated, it has no limitations on growth (apart from memory constraints). > Merging Lists is easier in case of Linked lists. > Breaking a List into two or more lists is easier in case of Linked lists.so Linked list is a better data structure in most cases. Arrays are goos mostly for static data structures.

Yes  1 User has rated as useful.
  
Login to rate this answer.
Arup Ratan Banerjee

Answered On : Jan 29th, 2007

All the above statements reveal that link list is of better data structure than that of Array.But if we want to perform Sorting ( Ex: Bubble Sort, Insertion Sort, Quick Sort) by means of Link List then the time complexity will be much more than that of implementing the same with an Array

  
Login to rate this answer.
sumit.manchanda

Answered On : Mar 2nd, 2007

Arrays are stored in contigious memory ie (if suppose arr[12] is an integer array containing 12 elemnts, if memory address of ist elemnt is say 1088 then memoy address of next element in array would be 1090 & the next memory address would be 1092 as size of an integer value is 2 bytes) where as in linked lists it is not the case. In linked lists elements are not stored in contigious memory allocations, in linklists  every node contins a pointer which contains the address of next node in linked list.

  
Login to rate this answer.
sumit.manchanda

Answered On : Mar 2nd, 2007

Arrays are stored in contigious memory ie (if suppose arr[12] is an integer array containing 12 elemnts, if memory address of ist elemnt is say 1088 then memory address of next element in array would be 1090 & the next memory address would be 1092  as size of an integer value is 2 bytes) whereas in linked lists it is not the case. In linked lists elements are not stored in contigious memory allocations, in linklists  every node contins a pointer which contains the address of next node in linked list.

  
Login to rate this answer.

According to me Arrays can't declared dynamically.i.e they can't allocate memory dynamically. when ever we want to add more eliments than the size of Array it is not possible.In the case of Linked lists we can dynamically create any no of nodes and insert them at any point.And deletion of eliments,insert eliment in the middle is also more easy here.Not only that If we want to store 10 eliments,inarrays we need 10*(Size of datatype) bytes contiguous memory locations. But in Linked lists there is no need of contiguous memory locations.But both have their own features,and disadvantages, at that time situation we should have deside which one fullfit for our applications.ThankUAshok

  
Login to rate this answer.
kpmsiva

Answered On : May 24th, 2008

View all answers by kpmsiva

Arrays are collections of repeated data items. Structures are complex data items made up of other data items, including, potentially, other structures and arrays. You can, of course, also have arrays of structures. Array can be useful when static type and for dynamic structure type.

  
Login to rate this answer.
tajinderkaur

Answered On : Dec 11th, 2008

View all answers by tajinderkaur

Memory for the array is assigned statically and for linked list dynamically

  
Login to rate this answer.
Renuka Negi

Answered On : Sep 19th, 2011

1. Array is a linear data structure but linked list is linear and non-linear data structure.
2. Array is expensive than linked list.

  
Login to rate this answer.
Parshotam

Answered On : Sep 20th, 2011

Array is a group of similar data items which sharing a common name we can defined it by the first data type, name of array and then the size as follows:

int array[10];

the data type can be from others also.

And link list on the other hand is different from the array link list contains the value and the address of the next connected node.

We use the link list because it is easy to understand.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.