码迷,mamicode.com
首页 > 其他好文 > 详细

Array vs Linked List

时间:2015-10-30 07:03:35      阅读:365      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

Access: Random / Sequential

1. Array element can be randomly accessed using index

2. Random access for element of linked list costs O(n) time

3. Generally, in linked list, elements are accessed sequentially

Memory Structure

1. Elements of array is stored in contiguous memoery locations.

2. Elements of linked list is stored at any available location. But the pointer to the memory location is stored in Previous Node.

Insertion / Deletion

Array takes more time.

Linked list takes O(1) time.

Memory Allocation

1. For array, memory should be allocated at Compile-Time.

2. For linked list, memory can be allocated at Run-Time.

 

Array vs Linked List

标签:

原文地址:http://www.cnblogs.com/ireneyanglan/p/4922274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!