开发者

Java and .NET: Why different sorting algorithms are used by default? [closed]

As it currently stands, this question is not a good fit开发者_高级运维 for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

Just wondering why Java and .NET Framework uses different sorting algorithm by default.

In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says:

In Java, the Arrays.sort() methods use merge sort or a tuned quicksort depending on the datatypes and for implementation efficiency switch to insertion sort when fewer than seven array elements are being sorted

In .NET Framework Array.Sort/List.Sort() uses Quick Sort as default sorting algorithm (MSDN):

List.Sort() uses Array.Sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.

By looking at the great "Comparison of algorithms" table we can see that both algorithms has pretty different behaviour from Worst Case and Memory Usage perspectives:

Java and .NET: Why different sorting algorithms are used by default? [closed]

Both Java and .NET are great Frameworks for Enterprise Solutions development, both has platforms for embedded development. So why they are using different sorting algorithm by default, any thoughts?

EDIT: I see that two persons already voted to close this quesion as not constructive. I believe Java and .NET are most popular development Frameworks so it would be really interesting to find any non trivial and interesting thoughts, perhaps facts!, regarding such decision.


Different development teams in two different companies came to different conclusions regarding the usual use case for their frameworks and components and have decided to implement accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜