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. mysql中 where与having的区别

    having子句与where有相似之处但也有区别,都是设定条件的语句.在查询过程中聚合语句(sum,min,max,avg,count)要比having子句优先执行.而where子句在查询过程中执行优 ...

  2. 前端逼死强迫症系列之javascript续集

    一.javascript函数 1.普通函数 function func(){ } 2.匿名函数 setInterval(function(){ console.log(123); },5000) 3. ...

  3. codeforces#1248D2. The World Is Just a Programming Task(括号匹配转化为折线处理)

    题目链接: http://codeforces.com/contest/1248/problem/D2 题意: 可以执行一次字符交换的操作 使得操作后的字符串,循环移位并且成功匹配的方案最多 输出最多 ...

  4. PHP 之去除代码中的注释

    测试文件代码如下: <?php /** * Created by PhpStorm. * User: Yang * Date: 2019/10/16 * Time: 10:25 */ // 计算 ...

  5. 小程序弹出toast,怎么优化代码

    因为toast是会重复调的,所以可以直接写在app里面 在所有的子页面去调这个就好了. 如果是设的none那就是 设置的 就是

  6. CSS绘制三角形—border法

    1. 实现一个简单的三角形 使用CSS盒模型中的border(边框)即可实现如下所示的三角形:   CSS实现简单三角形 实现原理: 首先来看在为元素添加border时,border的样子:假设有如下 ...

  7. 走进JavaWeb技术世界6:Tomcat5总体架构剖析

      本文以 Tomcat 5 为基础,也兼顾最新的 Tomcat 6 和 Tomcat 4.Tomcat 的基本设计思路和架构是具有一定连续性的. Tomcat 总体结构 Tomcat 的结构很复杂, ...

  8. Python实现协程

    什么是进程和线程 有一定基础的小伙伴们肯定都知道进程和线程. 进程是什么呢? 直白地讲,进程就是应用程序的启动实例.比如我们运行一个游戏,打开一个软件,就是开启了一个进程. 进程拥有代码和打开的文件资 ...

  9. web-msg-sender的https支持改造

    用的是nginx代理转发443到2120端口实现,官方说workman原生支持,没有实现(现象是 访问 htttps://域名:2120/ 超时,不知道是服务器问题还是什么) 后转为用nginx代理转 ...

  10. 安装openssh-server报Depends: openssh-client (= 1:6.6p1-2ubuntu2.8)错误

    SFTP称作“安全的FTP”,它使用ssh文件传输协议.所以我们需要安装openssh-server ubuntu自带的有openssh-client,所以可以通过 ssh username@host ...