Is it possible to create an Indexing on Linked List
Hi,
When comparing Arrays with LinkedList, i observed that, we can doindexing on Arrays which is not possible in case of LinkedList as it does not use the Contigious memory for allocation, so is it possible to overcome this limitation, i mean is it possible to create contigious memroy allocation for linkedlist ?
Pls clarify me on this.
Thanks
Kiran
Re: Is it possible to create an Indexing on Linked List
No. That would be an array. Linked lists have advantages and disadvantages. What are you trying to do?
Re: Is it possible to create an Indexing on Linked List
Hi, i have found that we can use vector present in C++ STL which could help in indexing the linked list.
Re: Is it possible to create an Indexing on Linked List
It's possible, but probably not useful. You want to choose your container based on the ways you need to access it. If you need random access by an index, you probably want an array anyways. If you need insertion and deletion of elements at any position very quickly then a linked list is better. Constructing an index of a linked list gives you the disadvantages of having long insertion/deletion time so you might just as well use a regular array (or vector) in the first place.