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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are all the classes and interfaces that are available in the collections?

697


How can we remove loops in a linked list? What are the functions of fast and slow pointers?

904


What happens if we put a key object in a hashmap which exists?

723


Which is better merge or quick sort?

754


List out the basic operations that can be performed on a stack?

671


How does a hashmap work?

721


In tree construction which is the suitable efficient data structure?

823


List some applications of multilinked structures?

709


What is worst case complexity algorithm?

694


Where the data structures are used?

744


List the area of applications of data structure.

1008


What is bubble sort used for?

630


Why use a tuple instead of a list?

666


Define the tree data structure.

699


How do you use the sort function?

660