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
Can we create object of interface?
What is oops in simple words?
What is encapsulation example?
Why do we use oop?
What do you mean by variable?
What is polymorphism explain its types?
Can enum be null?
when to use 'mutable' keyword and when to use 'const cast' in c++
Can you explain polymorphism?
What is overloading in oop?
What is coupling in oop?
to find out the minimum of two integer number of two different classes using friend function
What is debug class?what is trace class? What differences are between them? With examples.
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.
Can bst contain duplicates?