Partial sorting: Difference between revisions

Content deleted Content added
Heap-based solutions: remove unreferenced, hard to understand and possibly incorrect algorithm
AnomieBOT (talk | contribs)
m Dating maintenance tags: {{Unreferenced section}}
Line 26:
 
==Tournament algorithm==
{{unreferenced section|date=May 2014}}
Another method is the tournament algorithm. The idea is to conduct a knockout minimal round tournament to decide the ranks. It first organises the games (comparisons) between adjacent pairs and moves the winners to next round until championship (the first best) is decided. It also constructs the tournament tree along the way. Now the second best element must be among the direct losers to winner and these losers can be found out by walking in the binary tree in O(log ''n'') time. It organises another tournament to decide the second best among these potential elements. The third best must be one among the losers of the second best in either of the two tournament trees. The approach continues until we find ''k'' elements. This algorithm takes O(''n'' + k log ''n'') complexity, which for any fixed ''k'' independent of ''n'' is O(''n'').