Name an advantage of array over linked list?

Answer Posted / sumeet choudhury

Arrays have random access and less overheads compared to
Linked list have sequential access only with too much
overheads and no cache memory support.
On the other hand, arrays allow random access, while linked
lists allow only sequential access to elements. Singly-
linked lists, in fact, can only be traversed in one
direction. This makes linked lists unsuitable for
applications where it's useful to look up an element by its
index quickly, such as heapsort. Sequential access on
arrays is also faster than on linked lists on many machines
due to locality of reference and data caches. Linked lists
receive almost no benefit from the cache.

Another disadvantage of linked lists is the extra storage
needed for references, which often makes them impractical
for lists of small data items such as characters or boolean
values. It can also be slow, and with a naïve allocator,
wasteful, to allocate memory separately for each new
element, a problem generally solved using memory pools.

Is This Answer Correct ?    64 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we create object of interface?

597


What is oops in simple words?

571


What is encapsulation example?

543


Why do we use oop?

595


What do you mean by variable?

567






What is polymorphism explain its types?

672


Can enum be null?

581


when to use 'mutable' keyword and when to use 'const cast' in c++

1640


Can you explain polymorphism?

576


What is overloading in oop?

568


What is coupling in oop?

587


to find out the minimum of two integer number of two different classes using friend function

1635


What is debug class?what is trace class? What differences are between them? With examples.

1598


This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.

1630


Can bst contain duplicates?

661