benefit of linked list over dynamic array such as vector
Hi, I am on debate whether or not using vector or list from stl for my project that requires as much optimization as possible. Please give comments and suggestions. Thank you in advance.
I understand that vector requires additional O(N) memory size when vector is out of its capacity thus needs allocate more space but this is not the run time but rather the memory size (may be a small effect on run time). If I can estimate the max size of my vector then I can allocate memory for it before and then it becomes very fast. Also vector gives the benefit of accessing random elements directly while linked list does not. Vector takes O(1) where as it would take O(i) to access index i in a linked list.
I understand that vector requires additional O(N) memory size when vector is out of its capacity thus needs allocate more space but this is not the run time but rather the memory size (may be a small effect on run time). If I can estimate the max size of my vector then I can allocate memory for it before and then it becomes very fast. Also vector gives the benefit of accessing random elements directly while linked list does not. Vector takes O(1) where as it would take O(i) to access index i in a linked list.
