Runtime Complexity of .NET Generic Collection

 

I had to implement some data structures for my computational geometry class. Deciding whether to implement the data structures myself or using the build-in classes turned out to be a hard decision, as the runtime complexity information is located at the method itself, if present at all. So I went ahead to consolidate all the information in one table, then looked at the source code in Reflector and verified them. Below is my result.

  Internal Implement- 
ation
Add/insert Add beyond capacity Queue/Push Dequeue/
Pop/Peek
Remove/ 
RemoveAt
Item[i]/Find(i) GetEnumerator MoveNext
List Array O(1) to add, O(n) to insert O(n) - - O(n) O(1) O(1) O(1)
LinkedList Doubly linked list O(1), before/after given node O(1) O(1) O(1) O(1), before/after given node O(n) O(1) O(1)
Stack Array O(1) O(n) O(1) O(1) - - O(1) O(1)
Queue Array O(1) O(n) O(1) O(1) - - O(1) O(1)
Dictionary Hashtable with links to another array index for collision O(1), O(n) if collision O(n) - - O(1), O(n) if collision O(1), O(n) if collision O(1) O(1)
HashSet Hashtable with links to another array index for collision O(1), O(n) if collision O(n) - - O(1), O(n) if collision O(1), O(n) if collision O(1) O(1)
SortedDictionary Red-black tree O(log n) O(log n) - - O(log n) O(log n) O(log n) O(1)
SortedList Array O(n) O(n) - - O(n) O(1) O(1) O(1)
SortedSet Red-black tree O(log n) O(log n) - - O(log n) O(log n) O(log n) O(1)

Note:

Dictionary Add, remove and item[i] has expected O(1) running time
HashSet Add, remove and item[i] has expected O(1) running time

 
http://c-sharp-snippets.blogspot.com/2010/03/runtime-complexity-of-net-generic.html

Runtime Complexity of .NET Generic Collection的更多相关文章

  1. The C5 Generic Collection Library for C# and CLI

    The C5 Generic Collection Library for C# and CLI https://github.com/sestoft/C5/ The C5 Generic Colle ...

  2. Your algorithm's runtime complexity must be in the order of O(log n).

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  3. C# Collection

    数组与集合不同的适用范围: 数组:数组最适用于创建和使用固定数量的强类型化对象. 集合:集合提供更灵活的方式来使用对象组. 与数组不同,你使用的对象组随着应用程序更改的需要动态地放大和缩小. 对于某些 ...

  4. Instant Complexity - POJ1472

    Instant Complexity Time Limit: 1000MS Memory Limit: 10000K Description Analyzing the run-time comple ...

  5. 三部曲二(基本算法、动态规划、搜索)-1004-Instant Complexity

    Instant Complexity Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) ...

  6. [转]Dynamics AX and Generic collections of .Net

    转自:http://blogs.msdn.com/b/emeadaxsupport/archive/2009/04/23/dynamics-ax-and-generic-collections-of- ...

  7. Instant Complexity(模拟,递归)

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1535   Accepted: 529 Description Analyz ...

  8. Find that single one.(linear runtime complexity0

    public class Solution { public int singleNumber(int[] nums) { int temp = 0; for (int i=0;i<nums.l ...

  9. Generic Interfaces (C# Programming Guide)

    https://msdn.microsoft.com/en-us/library/kwtft8ak(v=vs.140).aspx It is often useful to define interf ...

随机推荐

  1. linux PHP 编译安装参数详解

    linux PHP 编译安装参数详解 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc -- ...

  2. 无边框窗体和timer控件

    一.无边框窗体 1.控制按钮如何制作就是放置可以点击的控件,不局限于使用按钮或是什么别的,只要放置的控件可以点击能触发点击事件就可以了 做的好看一点,就是鼠标移入(pictureBox1_MouseE ...

  3. [高斯消元] POJ 2345 Central heating

    Central heating Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 614   Accepted: 286 Des ...

  4. hadoop配置机架感知

    接着上一篇来说.上篇说了hadoop网络拓扑的构成及其相应的网络位置转换方式,本篇主要讲通过两种方式来配置机架感知.一种是通过配置一个脚本来进行映射:另一种是通过实现DNSToSwitchMappin ...

  5. 使用ajaxfileupload.js实现文件上传

    ajaxFileUpload是一个异步上传文件的jQuery插件 语法:$.ajaxFileUpload([options]) options参数说明: 1.url  上传处理程序地址. 2,file ...

  6. Windows 7下硬盘安装Ubuntu 14.04图文教程

    http://www.linuxidc.com/Linux/2014-04/100369.htm

  7. web开发流程(传智播客-方立勋老师)

    1.搭建开发环境 1.1 导入项目所需的开发包 dom4j-1.6.1.jar jaxen-1.1-beta-6.jar commons-beanutils-1.8.0.jar commons-log ...

  8. svn图标不显示的解决方案

    最近发现svn图标莫名其妙的不显示,其他操作都正常.在网上搜了一些方法. 解决方法一(失败): 升级最新版本,我的本来就是最新版本 解决方法二(失败): 右键->TortoiseSVN-> ...

  9. 例子:Execution Model Sample - 应用状态保存

    WP中,当你的应用被切换到后台 后,就进入了休眠状态,然后当一个应用从墓碑恢复时,如何恢复相应的状态,该例子就演示了如何保存和恢复UI以及APP相关状态. 这里有一篇很好的文章,请参见: http:/ ...

  10. 2.4G/5G频段WLAN各国使用信道表

    List of WLAN channels (维基百科):https://en.wikipedia.org/wiki/List_of_WLAN_channels 2.4G 5G 另附美国5G允许使用的 ...