Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   linked list in an array (http://www.go4expert.com/forums/linked-list-array-t23164/)

ali0482 1Sep2010 12:02

linked list in an array
Why is it difficult to store linked list in an array?

shabbir 1Sep2010 18:41

Re: linked list in an array
What do you mean by difficult?

virxen 2Sep2010 03:02

Re: linked list in an array
the difficult is not to store it in an array but to manipulate it.

xpi0t0s 2Sep2010 11:26

Re: linked list in an array
If you want to insert an item into the middle of the list, it's easy with a linked list cos you just redirect a couple of pointers. With an array you would have to move everything up a notch to create the free space. Also arrays tend to have a fixed size determined at compile time, whereas the size of a linked lists is determined at runtime.

But it's not difficult to store a linked list in an array; just loop over the list and copy the elements across one by one.

All times are GMT +5.5. The time now is 04:14.