what is the difference between arrays and linked list

Answer Posted / shruti

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
required.

there is no problem of memory shortage or wastage, in
linked list. which we very frequently come accross in the
arrays..

Is This Answer Correct ?    137 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;ia1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

2711


What is declaration and definition in c?

523


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

595


What is the explanation for cyclic nature of data types in c?

642


Explain the difference between structs and unions in c?

574






Explain how do you determine the length of a string value that was stored in a variable?

667


What is static function in c?

630


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2264


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

649


Is it possible to use curly brackets ({}) to enclose single line code in c program?

793


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1124


What are the primitive data types in c?

571


Explain output of printf("Hello World"-'A'+'B'); ?

970


What is an auto keyword in c?

641


Is calloc better than malloc?

571