Live data from Hacker News

Unconventional Sorting Algorithms

codingkaiser.blog

1–10 of 60 posts

Re: Unconventional Sorting Algorithms

#4
Bogosort is always a fun one, because I think its one of the better introductions to NP-complete problems.

If you imagine that there's no "easy" algorithm to return a sorted list (but sorted lists do exist), then the only methodology possible is to try all combinations. And you do this either systematically, or randomly.

Random NP-complete algorithms, such as WalkSAT, are quite good in practice. Systematic NP-complete algorithms, such as DPLL-SAT, are more "obvious" in how they work, and are sufficient for smaller sizes.

Re: Unconventional Sorting Algorithms

#9

Isn't 'sleep sort' linear with respect to array size? O(n) sort achieved?

It is if you ignore how the underlying OS implements multitasking and sleep() in particular. And the kernel-side implementation usually involves some kind of priority queue of sleeping threads. So taken as a whole sleep-sort is just an convoluted implementation of heap-sort that outsources the actual sorting to OS.

Re: Unconventional Sorting Algorithms

#10
I recently found a fun linear-time systolic sorting algorithm. I'd describe the serial implementation as unconventionally obvious. It's like insertion sort, without all the bother of swapping.

  def index_sort(a):
    n = len(a)
    output = [None] * n
    for i in range(n): #can run in parallel, damn the GIL
      index = 0
      for j in range(n):
        if a[j] 
Post reply on HN