Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer is implied here:</p> <blockquote> <p>Note that these operations may execute in time proportional to the index value for some implementations (the LinkedList class, for example)</p> </blockquote> <p>A linked list doesn't have an inherent index; calling <code>.get(x)</code> will require the list implementation to find the first entry and call <code>.next()</code> x-1 times (for a O(n) or linear time access), where an array-backed list can just index into <code>backingarray[x]</code> in O(1) or constant time. </p> <p>If you look at the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html" rel="nofollow noreferrer">JavaDoc for <code>LinkedList</code></a>, you'll see the comment</p> <blockquote> <p>All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index. </p> </blockquote> <p>whereas <a href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" rel="nofollow noreferrer">JavaDoc for <code>ArrayList</code></a> has the corresponding</p> <blockquote> <p>Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list. (This class is roughly equivalent to Vector, except that it is unsynchronized.)</p> <p>The <code>size</code>, <code>isEmpty</code>, <code>get</code>, <code>set</code>, <code>iterator</code>, and <code>listIterator</code> operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the <code>LinkedList</code> implementation. </p> </blockquote> <p>A <a href="https://stackoverflow.com/questions/559839/big-o-summary-for-java-collections-framework-implementations">related question titled "Big-O Summary for Java Collections Framework"</a> has an answer pointing to this resource, <a href="http://www.coderfriendly.com/wp-content/uploads/2009/05/java_collections_v2.pdf" rel="nofollow noreferrer">"Java Collections JDK6"</a> which you might find helpful. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload