why it is difficult to store linked list as an array?



why it is difficult to store linked list as an array? ..

Answer / codex

Its not difficult if you need to copy items in linked list to an array you should traverse the list starting first element and copy each value you pass by to an array.

if you are asking why do we use a linked list rather than array then it's because an array needs to have a fixed size but in a linked list you can add as much items as you can.but If you really need to use an array you can use an arraylist with resize feature.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What are b tree keys?

0 Answers  


How to find middle element of linked list in one pass?

0 Answers  


Write the postfix form of the expression: (a + b) * (c - d)

0 Answers  


How many types of priority queue are there?

0 Answers  


Explain implementation of traversal of a binary tree.

0 Answers  






On clicking a node in a tree, all the adjacent edges are turned on. Calculate min of clicks such that all the edges are turned on.

0 Answers   Aspiring Minds,


Why is quicksort not stable?

0 Answers  


What is difference between concurrenthashmap and hashtable?

0 Answers  


Is hashset a collection?

0 Answers  


How to reference all the elements in a one-dimension array?

0 Answers  


What are binary trees?

0 Answers  


What is difference between treeset hashset linkedhashset?

0 Answers  


Categories