Skip to content
 
 

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SlowDuckSort Banner

SlowDuckSort

A deliberately inefficient sorting algorithm that demonstrates the concept of space-time trade-offs taken to an impractical extreme.

It maps values into a sparse memory array using sum residuals, compacts the non-null elements, and flips the resulting structure to achieve ascending order.

Motivation

Most sorting algorithms optimize for speed and memory footprint. SlowDuckSort was designed as an experimental counter-example: what happens if an algorithm uses memory address translation based on array totals instead of traditional comparison loops?

The result is technically functional, visually distinct, but intentionally slow and memory-heavy.

How It Works

SlowDuckSortGIF

  1. Total Sum Calculation: The sum of all elements in the array is calculated.
  2. Sparse Array Mapping: For each element x, its placement index is calculated as: residual = total_sum - x The element is then placed at RAM[residual]. Unused slots remain empty (None).
  3. Compaction: The algorithm scans the sparse array, ignores all None values, and collects the placed elements side-by-side into a continuous array.
  4. Final Reversal: Since larger original values produce smaller residuals, the compacted array is naturally in descending order. A final flip reverses the array into ascending order.

About

A deliberately slow and memory-heavy sorting algorithm based on total sum residuals, sparse RAM mapping, and array reversal

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages