Beg Pardon? The only way a dynamic array implementation would require more memory than a linked list implementation for anything is when reallocating the buffer of the array to change its size.
In a singly-linked list, you are required to store an extra pointer with every item. With strings, assuming a pure linked list implementation, that's a pointer for every character, or a 400% increase in size (1 byte of string requiring 4 bytes of pointer) over an array of the same size?! Using a doubly-linked list (why? singly linked with pointer reversal is good enough for most applications
) will disimprove that to an 800% increase.
Using dynamic arrays, you are limited to the capacity of malloc(), which is governed by the size_t variable. Testing under linux, it worked for values up to 2147483647 before compiling with warnings... which is more space than I think most people have memory (by just a bit
)
As for efficiency, it really depends what you're planning on doing. Concatenating is done in constant time using linked lists, but most other operations are done in comparable (or better - substr becomes a memcpy
) time by the array. Sure, there's a slight internal memory loss just after increasing the size of the array, but with an efficient scheme this could be minimized (if it's even a problem) without needing to call realloc too often. (Again, depends on the string operations required)
I would recommend arrays, all the way!
Sorry for going on so long... I've just had this discussion too many times before :P
White Fire