How are there so many sorting algorithms?

Click For Summary

Discussion Overview

The discussion revolves around the question of whether there is a limit to the number of sorting algorithms that can be developed for the problem of sorting elements. Participants explore the nature of sorting algorithms, their variations, and the implications of algorithm design in relation to the simplicity of the sorting problem.

Discussion Character

  • Debate/contested
  • Exploratory
  • Conceptual clarification

Main Points Raised

  • Some participants suggest that unless strict criteria are defined, there could be infinitely many sorting algorithms.
  • Others argue that the diversity of sorting algorithms arises from their varying advantages and disadvantages, which depend on the data being sorted.
  • One participant notes that some sorting algorithms were developed before more efficient ones and that some serve primarily educational purposes.
  • There is a discussion about the common use of quick sort and merge sort in compiler libraries, with specific implementations mentioned.
  • Some participants express skepticism about whether there is a limit to the number of algorithms for sorting, proposing that one could always modify an existing algorithm to create a new one.
  • A later reply questions the meaningfulness of the original question, suggesting that since there is no way to count the number of solutions to a problem, the inquiry may be inherently flawed.
  • One participant references a book titled "The Art of Computer Programming" as a resource related to algorithms.

Areas of Agreement / Disagreement

Participants do not reach a consensus on whether there is a limit to the number of sorting algorithms. Some argue for the possibility of infinite algorithms, while others question the relevance of the inquiry itself.

Contextual Notes

The discussion touches on the complexity of defining sorting algorithms and the implications of algorithm modification, but does not resolve the underlying assumptions or definitions that could clarify the inquiry.

Avichal
Messages
294
Reaction score
0
I was looking through the list of sorting algorithms and there are so many of them! A simple problem where each element is less that or greater than the next term has so many solutions. How is that?

My question is a rhetorical one but is there any limit to number of different techniques for sorting?
Till now the algorithms I have read do the following:-
Selection sort: Finds the minimum and places in the first position and so on
Heap sort: Finds the minimum but in an efficient way using binary trees
Quick sort and Merge sort: Use divide and conquer
Insertion sort: Finds the correct position and places element there

Surely there is a limit to number of different techniques for sorting, right?
 
Technology news on Phys.org
Unless you specify some strict criteria for admissible sorting algorithms, there are infinitely many of them.
 
We study so many different sorting algorithms because they have different combinations of advantages and disadvantages, which often depend on the kind of data being sorted.
 
Some of the sort algorithms were developed before similar but faster algorithms were discovered, and some are mostly educational and don't offer any significant advantages. As an example of the latter, top down merge sort recursively splits an array into two until repeated recursion produces arrays of size 1, by generating indices stored on the stack during recursion, at which point the merge process begins and flows back up the call chain. Bottom up merge sort skips the unneeded recursive process and just starts off by considering an array of size n to be n arrays of size 1, and uses iteration to generate indices as needed during the merge process.

The most common sort algorithms found in compiler libraries are variations of quick sort and merge sort. Microsoft / HP C++ Standard Template Library uses quick sort for array / vector types if the original order for equal elements does not need to be preserved called std::sort(), and merge sort if the original order needs to be preserved called std::stable_sort(), and also uses merge sort and an array of list structures (the head and tail pointers) for sorting linked lists called std::list::sort().

Non-comparason sorts like radix sort are fastest if sorting a large array of 4 to 16 byte integers or something similar where the length of the data that determines the sort order is relatively small.
 
I am not asking why we have so many sorting algorithms.
I'm asking whether there is a limit to number of algorithms to such a simple problem?

I guess my question can be generalized as follows:- Given a problem, is there a limit to number of algorithms to the problem.

While for a complicated problem, there might be infinitely many solutions but in this case i.e. sorting is there a limit? What else can you do to sort apart from the known algorithms?
 
Avichal said:
I'm asking whether there is a limit to number of algorithms to such a simple problem?

You were given an answer to this.

I guess my question can be generalized as follows:- Given a problem, is there a limit to number of algorithms to the problem.

Obviously not. If you have an algorithm that produces at least one bit, you can add a step that flips that bit, and another step that flips it back. The result is the same as in the original algorithm. You can add infinitely many steps like that, getting infinitely many algorithms.
 
voko said:
Obviously not. If you have an algorithm that produces at least one bit, you can add a step that flips that bit, and another step that flips it back. The result is the same as in the original algorithm. You can add infinitely many steps like that, getting infinitely many algorithms.

Ah, I didn't think this in such detail. Probably I should ask whether there are infinitely many ideas or techniques to sort? Anyways, I guess there are indeed infinitely many ways to sort.
Also since there is no way to count number of solutions to a problem, the question is meaningless.
 
their is a 4 volume book called The art of algorithms, flip through it sometime.
 
The Art of Computer Programming I mean,lol
 
  • #10
Perhaps a visualization will help.

https://www.youtube.com/watch?v=kPRA0W1kECg
 
  • #11
Cool video!
Anyways I don't have any trouble understanding the algorithms. I was only interested if there is a limit to the number of algorithms
 

Similar threads

Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K