Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://leepoint.net/notes-java/algorithms/big-oh/bigoh.html" rel="noreferrer">This page</a> summarises some of the time comlplexities for various collection types with Java, though they should be exactly the same for .NET.</p> <p>I've taken the tables from that page and altered/expanded them for the .NET framework. See also the MSDN pages for <a href="http://msdn.microsoft.com/en-us/library/f7fta44c.aspx" rel="noreferrer">SortedDictionary</a> and <a href="http://msdn.microsoft.com/en-us/library/ms132319.aspx" rel="noreferrer">SortedList</a>, which detail the time complexities required for various operations.</p> <hr> <h2>Searching</h2> <pre> <b>Type of Search/Collection Types Complexity Comments</b> Linear search Array/ArrayList/LinkedList O(N) Unsorted data. Binary search sorted Array/ArrayList/ O(log N) Requires sorted data. Search Hashtable/Dictionary&lt;T&gt; O(1) Uses hash function. Binary search SortedDictionary/SortedKey O(log N) Sorting is automated. </pre> <h2>Retrieval and Insertion</h2> <pre> <b>Operation Array/ArrayList LinkedList SortedDictionary SortedList</b> Access back O(1) O(1) O(log N) O(log N) Access front O(1) O(1) N.A. N.A. Access middle O(1) O(N) N.A. N.A. Insert at back O(1) O(1) O(log N) O(N) Insert at front O(N) O(1) N.A. N.A. Insert in middle O(N) O(1) N.A. N.A. </pre> <p>Deletion should have the same complexity as insertion for the associated collection.</p> <p>SortedList has a few notable peculiarities for insertion and retrieval.</p> <p><em>Insertion (Add method):</em></p> <blockquote> <p>This method is an O(n) operation for unsorted data, where n is Count. It is an O(log n) operation if the new element is added at the end of the list. If insertion causes a resize, the operation is O(n).</p> </blockquote> <p><em>Retrieval (Item property):</em></p> <blockquote> <p>Retrieving the value of this property is an O(log n) operation, where n is Count. Setting the property is an O(log n) operation if the key is already in the SortedList&lt;(Of &lt;(TKey, TValue>)>). If the key is not in the list, setting the property is an O(n) operation for unsorted data, or O(log n) if the new element is added at the end of the list. If insertion causes a resize, the operation is O(n).</p> </blockquote> <p>Note that <code>ArrayList</code> is equivalent to <code>List&lt;T&gt;</code> in terms of the complexity of all operations.</p> <hr>
    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.
 

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