The MASM Forum

General => The Laboratory => Topic started by: Raistlin on March 28, 2020, 03:46:37 AM

Title: Rule of thumb on Sorting...supposedly
Post by: Raistlin on March 28, 2020, 03:46:37 AM
Disclaimer:
More of a click-bait post, counter to my normal musings.
You have been warned. :undecided:

Consider please....
Sorting algos listed fastests (above others in
the same grouping [Log Scale] as proclaimed generizable assertion)
according to assembly enthusiast you-tuber (reference on PM request
if interested):
Small number of elements = Insertion sort (max 50 to 100 elements) 
Mid size number of elements = STD-STL sort (up to max 1500 or so)
Large sizes = Radix sort (very large 2000+ and beyond)

Your thoughts appreciated. My own crappy code attempt
to follow.

Regards
Raistlin
Title: Re: Rule of thumb on Sorting...supposedly
Post by: daydreamer on March 28, 2020, 05:45:03 AM
Different way of sort, new kinda challenge , wonder what will be fastest with unicode Chinese numbers?,ascii is simple 0-9 all in right order
Chinese unicode number characters, is random order 1,2,3,4,5,6,7,8,9,10,100,1000,10000...
Is placed maybe complexity or number of lines among cjk kanji characters?
http://masm32.com/board/index.php?topic=8416.msg92116#new (http://masm32.com/board/index.php?topic=8416.msg92116#new)
Title: Re: Rule of thumb on Sorting...supposedly
Post by: jj2007 on March 28, 2020, 11:02:18 AM
Quote from: Raistlin on March 28, 2020, 03:46:37 AM
Large sizes = Radix sort (very large 2000+ and beyond)

ArraySort() (http://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1176) uses a radix sort. It is very fast, and beats all other algos when sorting small integers, e.g. up to 2^16 or so. For strings I use a stable MergeSort instead.

For all sorts 2000+ is not "very large" but rather "tiny". Sorting 44,000 strings takes typically 70ms, but for one Million strings you need a full second. Sorting small numbers of elements (<10,000) is always blazing fast. The real challenge starts above one Million.
Title: Re: Rule of thumb on Sorting...supposedly
Post by: Adamanteus on March 28, 2020, 10:18:17 PM
Maybe you'll be interested in Skip-list (http://en.wikipedia.org/wiki/Skip_list) algo for Large sizes lists.
Title: Re: Rule of thumb on Sorting...supposedly
Post by: jj2007 on March 29, 2020, 01:29:34 AM
Quote from: Adamanteus on March 28, 2020, 10:18:17 PM
Maybe you'll be interested in Skip-list (http://en.wikipedia.org/wiki/Skip_list) algo for Large sizes lists.

Quotea linked list-like structure that allows insertion, which is not possible in an array

Written by a linked list fan :cool:
Title: Re: Rule of thumb on Sorting...supposedly
Post by: Adamanteus on March 29, 2020, 07:45:08 AM
Quote from: jj2007 on March 29, 2020, 01:29:34 AM
Written by a linked list fan :cool:
Really, I mean algo that in cases decrease amount of comparations, for sorting algo - for huge amount of data good.
Title: Re: Rule of thumb on Sorting...supposedly
Post by: daydreamer on March 29, 2020, 09:55:32 PM
special case:but wasnt BSP tree slowest when precalculating and fastest when its just traverse a Binary tree to a leaf that tells it which walls are visible?