【问题标题】:Array over Linked list examples链表上的数组示例
【发布时间】:2015-07-13 21:41:53
【问题描述】:

在一次采访中,有人问我什么时候数组优于链表? 面试官对我给出的差异不满意,他实际上是在问一些例子。

【问题讨论】:

标签: arrays data-structures linked-list


【解决方案1】:

数组和链表的一些例子或用法是。

数组。

Arrays are used when the number of items to be stored are known beforehand.

Arrays are used when we want to access the elements through their index (binary search).

Arrays use less memory as compared to linked list.

Sorting in an array is easier.

链表。

Linked list is used when amount of data is not known beforehand.

Linked list takes more memory, as it uses pointer field.

Linked list is comparatively hard to implement.

Sorting a linked list is quite difficult.

【讨论】:

    猜你喜欢
    • 2011-05-16
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 2012-11-11
    相关资源
    最近更新 更多