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 is difference between linear and non linear data structure?

0 Answers  


How can we delete the first node from the singly linked list?

0 Answers  


Which is better merge or quick sort?

0 Answers  


You are given a singly linked list. How would you find out if it contains a loop or not without using temporary space?

0 Answers   TCS,


Define a linear data structure.

0 Answers  


Explain what is linear search?

0 Answers  


Which collection is fail safe?

0 Answers  


What is sort in data structure?

0 Answers  


What you mean by sorting?

0 Answers  


How do you do a mergesort?

0 Answers  


What is queue in data structure?

0 Answers  


What do you mean by data and data structure?

0 Answers  


Categories