概念题

作者: 夜皇雪 | 来源:发表于2016-11-21 03:21 被阅读0次
    Screen Shot 2016-11-18 at 5.22.16 PM.png

    Explain

    1. Get: ArrayList maintains index based system for its elements as it uses array data structure implicitly which makes it faster for searching. LinkedList implements doubly linked list which requires the traversal through all the elements for searching.
    2. Remove & Add: LinkedList’s each element maintains two pointers which points to the both neighbor elements. Hence removal only requires change in the pointer location in the two neighbor nodes of the node which is going to be removed. While In ArrayList all the elements need to be shifted to fill out the space created by removed element.
    3. Memory Overhead: ArrayList maintains indexes and element data while LinkedList maintains element data and two pointers for neighbor nodes.

    When to use LinkedList and ArrayList?

    If there is a requirement of frequent addition and deletion in application then LinkedList is a best choice.

    If there are less add and remove operations and more search operations requirement, ArrayList would be your best bet.

    相关文章

      网友评论

          本文标题:概念题

          本文链接:https://www.haomeiwen.com/subject/hgwspttx.html