Name an advantage of array over linked list?

Answer Posted / eren tsanglao

Array can be access randomly and it can even access the
middle element by just the array name with the
subscript,eg, a[5].The elemente are allocated a contagious
memory.Whereas in linked list more space is required for
the pointer and the information.Accessing elements in
linked list is sequential.

Is This Answer Correct ?    26 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the problem with multiple inheritance?

578


What is the fundamental idea of oop?

629


What is static modifier?

626


What is protected in oop?

598


Why is oop better than procedural?

600






Which type does string inherit from?

608


what type of question are asked in thoughtworks pair programming round ?

1754


What is polymorphism in oops with example?

525


Write a program to sort the number with different sorts in one program ??

1910


What is advantage of inheritance?

683


Whats oop mean?

584


What is difference between polymorphism and inheritance?

611


What is overloading and its types?

608


How Do you Code Composition and Aggregation in C++ ?

24185


#include #include #include #include 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.

3240