Let me try to answer the first one, based on my data stucture knowledge

sailor (Sailor)

The elements of an array are stored together in consecutive addresses;

The linked list members may be scattered in the variable area of the memory.

Array allows you to access its elements randomly or consecutively; while no random access is available for linked lists' element.

If you want to add new element into an array, you may probably use the "append" operation rather than "insert" --an insert-into-middle operation may take relatively long time;

You can insert an element into a linked list in any place of the list, without big trouble.

If you want to delete an element from an array --you caused a blackhole --or you have to spend big time to compress the array;

To delete elements from linked list, it's very simple and easy and it takes a almost contant time.

To traverse the whole container, it's faster in an array.

2000-12-2 -04:00

回到话题: C++ questions

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论