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

sailor (Sailor)
1,

a,
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.

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

c,
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.

d,
To traverse the whole container, it's faster in an array.
(#16877@0)
2000-12-2 -05:00

回到话题: C++ questions

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

URL:   
http://www.rolia.net/zh/post.php?f=0&p=16877