Name an advantage of linked list over array?
Answers were Sorted based on User's Feedback
Answer / manoj kumar jha
1. Array size is fix and cannot change at run time,But in
link list we can create memory accoring to requirement.
2. In array we define but at the run time it is not used so
in that case memory is waste.
Is This Answer Correct ? | 44 Yes | 3 No |
Answer / ritesh parkhi
array always contain static memory location even linklist
contain dynamic memory location.In once declaration of an
array we can store smae type of data but in linkedlist
hetrogeneous link list is possible which can be contain
diffrent diffrent types of data type in linkedlist.in link
list we are using void pointer.
Is This Answer Correct ? | 33 Yes | 4 No |
Answer / satish kondapalli
computer memory is divided into blocks.each work use these
blocks in non-contigious manner.but array elements are
stored in continous memory allocation.this will adversely
affect unuse of the memory blocks.array searches for bigger
blocks it needed,so that many small nlocks of memory is
unused.the main advantage of linkedlist is it can use
non-continuous memory blocks,because of it has the relation
between the nodes,and this is main merit over array.
Is This Answer Correct ? | 16 Yes | 1 No |
Answer / azhar iqbal
Array is of fix size & contain always same type of data.
Whereas linklist is dynamic in size.And a type of linklist
have capability to store different type of data at its
nodes, and for doing that we use void pointer( a pointer
that can point any type of data )
Is This Answer Correct ? | 14 Yes | 2 No |
Answer / kabir
Insertion & deletion are relatively easy in linked list.
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / amandeep singh bhatia
In array we can directly access any element by index number
but in Linked list it is not possible,in linked list if we
want to access any element then we go from starting node.
Is This Answer Correct ? | 12 Yes | 8 No |
Answer / dinesh kumar thakur jalandhar
------> in case of linklist no continuous memeory is
required .but in case of array there is of need continuous
memory block , mean to say if we have enough free memory but
is not in continuous block than we can not use it in case of
array .
but same memery can be used in case of linklist.
Is This Answer Correct ? | 6 Yes | 3 No |
Answer / amarpreet
getting an element from array is easybut from linked list
it is difficult because you have to search from start node
and traverse through each and every node
Is This Answer Correct ? | 10 Yes | 8 No |
Answer / ranveer singh
array contains static memory even linklist contains dynamic
mrmory location
Is This Answer Correct ? | 0 Yes | 1 No |
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
What are the advantages of inheritance?
26 Answers IBS, TCS,
tell about copy constructor
#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; a.x = 22; int c = a.x; int *b = new int; cout << c; return 0; } option: No output 0 22 -(11) Will not compile
What is difference between abstraction and encapsulation?
Can you explain polymorphism?
what is multithreading in c++ , what is difference between multithreading and singlethreading.
#include <stdio.h> #include <alloc.h> #include <stdlib.h> #include <conio.h> void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.
different types of castings
difference between class and object
10 Answers Chandan, IBM, Magic Soft,
What is the default size allocated for array in the statement if size not specified " int a[] "
How do you make derived class as an abstract class?