A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-March/138667.html below:

[Python-Dev] Tunning binary insertion sort algorithm in Timsort.

[Python-Dev] Tunning binary insertion sort algorithm in Timsort. [Python-Dev] Tunning binary insertion sort algorithm in Timsort.nha pham phqnha at gmail.com
Mon Mar 9 01:17:16 CET 2015
We can optimize the TimSort algorithm by optimizing its binary insertion
sort.



The current version of binary insertion sort use this idea:

Use binary search to find a final position in sorted list for a new element
X. Then insert X to that location.



I suggest another idea:

Use binary search to find a final postion in sorted list for a new element
X. Before insert X to that location, compare X with its next element.

For the next element, we already know if it is lower or bigger than X, so
we can reduce the search area to the left side or on the right side of X in
the sorted list.



I have applied my idea on java.util. ComparableTimSort.sort() and testing.
The execute time is reduced by 2%-6% with array of random integer.



Here is detail about algorithm and testing:
https://github.com/nhapq/Optimize_binary_insertion_sort



Sincerely.

phqnha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150308/9e3a5cd3/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4