There are a huge number of sorting algorithms out there, but most of them only work on totally-ordered sets because they assume that any two elements are comparable. However, are there any good algorithms out there for sorting posets, where some elements are uncomparable? That is, given a set S of elements drawn from a poset, what is the best way to output an ordering x1, x2, ..., xn such that if xi ≤ xj, i ≤ j?
相关问题
- How to toggle on Order in ReactJS
- PHP Recursively File Folder Scan Sorted by Modific
- Change sort order of strings includes with a speci
- quicksort an array and do binary search in java
- Union of many (more than two) polygons without hol
相关文章
- Sort TreeView Automatically Upon Adding Nodes
- Should client-server code be written in one “proje
- Algorithm for maximizing coverage of rectangular a
- Is there an existing solution for these particular
- Why does array_unique sort the values?
- Sorting a data stream before writing to file in no
- Sort a List by a property and then by another
- What is Scope Creep? [closed]
Topological sort is well-suited to sorting a partially ordered set. Most algorithms are O(n^2). Here's an algorithm from Wikipedia:
There's a helpful video example. Most Unix-like systems have the
tsort
command. You could solve the video's brownie example withtsort
as follows:I'd start with selection-exchange sort. That's O(n^2) and I don't think you'll do better than that.
There's a paper titled Sorting and Selection in Posets available on arxiv.org which discusses sorting methods of order O((w^2)nlog(n/w)), where w is the "width" of the poset. I haven't read the paper, but it seems like it covers what you are looking for.