https://archive.codeplex.com/?p=timsort4net#117964

download archive https://codeplexarchive.blob.core.windows.net/archive/projects/timsort4net/timsort4net.zip



Project Description
TimSort is relatively new sorting algorithm invented by Tim Peters in 2002, which is a hybrid of adaptive MergeSort and InsertionSort. It is not worse than QuickSort which modified version is used as default sorting algorithm in .NET. TimSort's average case performance is O(n log n) (same as QuickSort) but both best case and worst case performances are bettern then QuickSort: O(n) and O(n log n) respectively (QuickSort is O(n log n) and O(n^2)). This implementation is a C# translation of Josh Bloch's Java implementation of TimSort. Wikipedia: http://en.wikipedia.org/wiki/Timsort Josh Bloch's Java implementation: http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/TimSort.java?view=co TimSort takes advantage of two facts: data we sort is often already partially sorted
comparison might be expensive (complex Compare method) while swapping elements is cheap (swapping pointers) When comparison gets slower (for example, comparing complex objects) TimSort increases its advantage over QuickSort. Array of 5368709 items, quick compare function: (actually: int.CompareTo(int)) Random data
Builtin: 1859.4927ms
TimSort: 1773.2582ms
Generally ascending data (80% chance that next item is greater than previous one)
Builtin: 1166.6400ms;
TimSort: 247.1780ms
Generally descending data (80% chance that next item is smaller than previous one)
Builtin: 1190.5521ms
TimSort: 571.7132ms NOTE: TimSort's performance is the same for random data, but is significantly better for already ordered data. Array of 536870 items, quite slow compare function (I actually added Thread.Sleep(0) to it): Random data
Builtin: 6117.1032ms
TimSort: 4578.1129ms
Generally ascending data (80% chance that next item is greater than previous one)
Builtin: 5323.7977ms
TimSort: 841.0910ms
Generally descending data (80% chance that next item is smaller than previous one)
Builtin: 5321.9103ms
TimSort: 1094.5267ms NOTE: TimSort's performance is better than QuickSort's when compare function is slow, even for random data.

Python's listobject.c – the C implementation of Timsort used in CPython

https://github.com/python/cpython/blob/master/Objects/listobject.c

https://sikasjc.github.io/2018/07/25/timsort/

http://hg.savannah.gnu.org/hgweb/octave/file/0486a29d780f/liboctave/util/oct-sort.cc

https://csharp.hotexamples.com/examples/-/List/TimSort/php-list-timsort-method-examples.html

Timsort的更多相关文章

  1. 简易版的TimSort排序算法

    欢迎探讨,如有错误敬请指正 如需转载,请注明出处http://www.cnblogs.com/nullzx/ 1. 简易版本TimSort排序算法原理与实现 TimSort排序算法是Python和Ja ...

  2. TimSort in Java 8

    在项目中使用了Collections.sort(list, comparator)对集合进行了排序,偶然间遇到异常IllegalArgumentException: "Comparison ...

  3. TimSort算法分析

    Timsort是一种混合稳定的排序算法,采用归并排序混合插入排序的设计,在多种真实数据上表现良好. 它基于一个简单的事实,实际中大部分数据都是部分有序(升序或降序)的. 它于2002年由Tim Pet ...

  4. Java TimSort算法 源码 笔记

    本来准备看Java容器源码的.但是看到一开始发现Arrays这个类我不是很熟,就顺便把Arrays这个类给看了.Arrays类没有什么架构与难点,但Arrays涉及到的两个排序算法似乎很有意思.那顺便 ...

  5. Timsort 算法

    转载自:http://blog.csdn.net/yangzhongblog/article/details/8184707 Timsort是结合了合并排序(merge sort)和插入排序(inse ...

  6. JDK(二)JDK1.8源码分析【排序】timsort

    如无特殊说明,文中的代码均是JDK 1.8版本. 在JDK集合框架中描述过,JDK存储一组Object的集合框架是Collection.而针对Collection框架的一组操作集合体是Collecti ...

  7. TimSort学习资料

    深入理解 timsort 算法(1):自适应归并排序 如何找出Timsort算法和玉兔月球车中的Bug? Java TimSort算法 源码 笔记 Timsort https://en.wikiped ...

  8. TimSort Java源码个人解读

    /*JDK 1.8 */ package java.util; /** * A stable, adaptive, iterative mergesort that requires far fewe ...

  9. Arrays.sort() ----- TimSort

    Arrays.sort() Arrays.sort()对于基本类型使用的是DualPivotQuicksort双轴快速排序,而对于非基本类型使用的是TimSort,一种源自合并排序和插入排序的混合稳定 ...

随机推荐

  1. CSPS2019游(tuifei)记

    %%%脸哥没脸%%% Day0,日常考前紧张,做不下题去.听各大主任送祝福(从里红(wa)到外) 然后就出发了,大巴上和云力一起坐,吃了好多东西.中午因不满火车站的不合理收费,选择了面包+火腿 下午在 ...

  2. python 里列表 extend 与 append 的区别

    extend 只能添加以列表形式的,而 append 可以添加任何的. 来自别人家的官方句子: extend 与 append 方法的相似之处在于都是将新接收到参数放置到已有列表的后面.而 exten ...

  3. notepad++修改背景色

  4. 在win10环境下IED配置spark项目

    eclipse在对spark的支持上并不友好,所以需要新下载并安装IntelliJ IDEA 2019.1.我下载安装的是专业版的,直接在网上搜索了破解码进行破解. 1. 配置java和scala I ...

  5. FOI 冬令营 Day6

    目录 T1.堆(heap) 传送门 Code T2.密文(secret) 传送门 Code T3.树(tree) 传送门 Code 别问Day5到底去哪里了,咕咕咕 T1.堆(heap) 传送门 Co ...

  6. 在使用avalon框架的时候,用ms-duplex双工绑定,在template上是有数据渲染的,但是js里面却是undefined

    controller绑定是用于圈定某个VM的作用域范围,因为有的页面,你用的对象一致,而这两个作用域里面有相同的数据,那么很有可能是另一个作用域里面的东西影响了这个作用域,所以在指定作用域的给不同的命 ...

  7. JMeter-因cookie管理器不兼容返回H5内容内容的解决

    问题: 使用的post方法但是显示的是get,并且返回页面H5的内容 解决: jmeter版本太低了,需要选择cookie管理期选择兼容模式(一般默认的为standard)

  8. NTC热敏电阻温度计算方法,Steinhart-Hart方程和B值法(转)

    NTC热敏电阻计算器使用方法 NTC热敏电阻计算器 V1.0 10K负温度系数热敏电阻(NTC)温度与阻值对应关系表 Rt = R(25℃)*EXP[B*(1/T - 1/(T+25))] 说明: 1 ...

  9. Oracle 11g 监听很慢,由于监听日志文件太大引起的问题(Windows 下)

    现象:Windows 操作系统的Oracle 数据库,使用sqlplus 连接(不指定实例名)连接很快,程序连接或使用连接工具或在Net Manager 中测试连接都需要花费约三四十秒的时间(程序连接 ...

  10. 38 Flutter仿京东商城项目 渲染结算页面商品数据

    加群452892873 下载对应38课文件,运行方法,建好项目,直接替换lib目录 CartServices.dart import 'dart:convert'; import 'Storage.d ...