Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load Sort
#3
This really isn't a very efficient sort.  ;(

For starters, your find the index on a linear search -- from start to finish.  For 1000 items, that's 1000 comparisons to just *find* where to do the insert.  At least swap that to a binary search method.

1000 items.  Check 500.  250. 125. 62. 31. 15. 7. 3. 1. 0  <-- 10 checks MAX just found where to insert that new data, rather than 1000 max sequential checks.

Then inserting the data is a case of "shift every item right 1 element" from insert point to end of array.  Again, not very efficient.  Use _MEM, grab the whole block, move it all at once.

I've got a copy of this Binary Insertion Sort which uses mem either floating around here, or on the old forums somewhere.  I'll see if I can dig it up for you later sometime, if you're interested in comparing its speed to yours.  Wink
Reply


Messages In This Thread
Load Sort - by bplus - 04-29-2024, 07:17 PM
RE: Load Sort - by bplus - 04-29-2024, 07:23 PM
RE: Load Sort - by SMcNeill - 04-29-2024, 07:37 PM
RE: Load Sort - by bplus - 04-29-2024, 08:18 PM
RE: Load Sort - by bplus - 04-30-2024, 02:24 AM
RE: Load Sort - by bplus - 04-30-2024, 08:27 PM
RE: Load Sort - by SMcNeill - 04-30-2024, 08:35 PM



Users browsing this thread: 1 Guest(s)