what is the difference between arrays and linked list
Answers were Sorted based on User's Feedback
Answer / sumit thokal
arrays are linear data structure
while linked lists are linear and non-linear
in case of linked list :-from point of access strategy it
is linear and from point of storage strategy it is non
|Is This Answer Correct ?||233 Yes||57 No|
the main differance between arrays and linked list is:
In array we follow static memory allocation.
i.e we assign memory to the particular element in advance.
in linked list -> dynamic memory allocation.
i.e we assign memory to the particular element at run-time..
hence we reserve only the amount of memory which is
there is no problem of memory shortage or wastage, in
linked list. which we very frequently come accross in the
|Is This Answer Correct ?||136 Yes||21 No|
Answer / jaroosh
>Array is a simple sequence of numbers which are not
>concerned about each-others positions.
This is not true, what about arrays of objects ? They may be
concerned about each other in some way.
>adding,removing or modifying any array element is very >easy.
This is untrue also, adding, removing elements in array is
significantly more complex than removing or adding elements
in linked list. This is because removing elements from array
causes all elements after it to be shifted back, whereas
with linked list, its merely traversing the list to find the
node, previous node, and the next node and setting pointers,
and inserting element into array will probably call for
1) resizing the whole array size (ie. assingning a new,
bigger memory chunk for it)
2) copying elements from the former smaller array to the new
- bigger one.
This is a huge trade off, provided that in list, its simply
matter of setting the NEXT pointer of one of the nodes.
Main differences between the two are:
1) arrays are RANDOM ACCESS structures, where you can access
elements in random/indexed manner, whereas list is a
sequential access structure. This makes such algorithms like
heap sort or binary search to work much faster on arrays
2) arrays are static/fixed size whereas lists are dynamic
size structures. It means that when creating an array (both
on stack or heap), you HAVE to specify its size. With lists,
you just create an empty list and freely expand it
3) array consist of continuous chunks of memory, ie. nth
element is at the memory location of :
address_of_array + sizeof(array_element_type) * n
this always holds true, that is why following will always work :
for(int i=0;i < ARRAY_SIZE; i++)
cout << *(array++);
List is a sequence of nodes, connected by NEXT pointers, so
consequent nodes may lie WHEREVER in memory
|Is This Answer Correct ?||122 Yes||22 No|
Answer / kshama
Array is a simple sequence of numbers which are not
concerned about each-others positions. they are independent
of each-others positions. adding,removing or modifying any
array element is very easy.Compared to arrays ,linked list
is a comlicated sequence of numbers.each number in the
linked list is connected to its previous & next no. via a
link which is nothieng but a pointer.Addition,removal of
no.s in linked list is related to this pointer direction &
linking that no. to the no. which is already present in the
|Is This Answer Correct ?||137 Yes||47 No|
Answer / yoga
Both are nothing but the data structures where in arrays
data can be accessed using subscript but in linked list
data can be accessed by the pointer present in its previous
|Is This Answer Correct ?||59 Yes||15 No|
Answer / bhumika garg
the main difference is that in array data is not linked to
each other but in linked lists data is connected to each
other as every node is connected to previous node.
|Is This Answer Correct ?||47 Yes||14 No|
Answer / vasu kanneganti
1.array is fixed length and Array is a simple sequence of
numbers which are not concerned about each-others positions
but linked list is variable length
2.in array values are accessing easy but linked list is
some time taken process bcoz search aither forword or
3.in array updating operations are time taken comparing
4.array is not growble and linkedlist is growble
|Is This Answer Correct ?||42 Yes||14 No|
Answer / priya
All elements of array stored in contiguous memory location.
While in case of linked list each node does not stored in
contiguous memory location
|Is This Answer Correct ?||25 Yes||6 No|
Answer / durairaj
1.Easy to use
2.No memory management needed
3.Can access any element by index
4.Fairly quick to loop
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)
1.Dynamic size (can increase or decrease the list)
2.No memory is wasted
1.Lots of overhead code (lots of malloc calls and assigning
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
|Is This Answer Correct ?||23 Yes||4 No|
Answer / soumen goswami
1)Array has a static storage where as in linked list it is
2)To add some elements in an array is impossible since the
size is predefined.For the same case we can add elements at
the beginning,in the middle and also in the end.
3)To access the data from array is very easy while to access
data from linked list is some complex.
|Is This Answer Correct ?||25 Yes||9 No|
Write an interactive c program that will encode or decode a line of text. To encode a line of text, proceed as follows: Convert each character, including blank spaces, to its ASCII equivalent. Generate a positive random integer. Add this integer to the ASCII equivalent of each character. The same random integer will be used for the entire line of text. Suppose that N1 represents the lowest permissible value in the ASCII code, and N2 represents the highest permissible value. If the number obtained in step 2 above exceeds N2, then subtract the largest possible multiple of N2 from this number, and add the remainder to N1. Hence the encoded number will always fall between N1 and N2, and will therefore always represent some ASCII character. Display the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text. Be certain, however, that the same random number is used in decoding as was used in encoding.
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
how can use subset in c program and give more example
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
1. Can we use the for loop this way? for(;i>5;) 2. What is the use of pointers? 3. what is array of pointer? 4. What is the difference between file and database? 5. Define data structure?
from which concept of 'c', the static member function of 'c++' has came?
post new interiew question and aptitude test papers
I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
Write a program for deleting duplicate elements in an array
Develop a program that computes the new price of an item. The program should receive a character variable colour and a double precision floating-point variable price from the user. Discount rate is determined based on the colour of the discount sticker, as shown in the following table. An error message should be printed if an invalid colour has been entered
what is constant pointer?