2009年11月3日
摘要: Merge sort is an O(n log n) comparison-based sorting algorithm. In most implementations it is stable, meaning that it preserves the input order of equal elements in the sorted output. It is an example... 阅读全文
posted @ 2009-11-03 17:39 lantionzy 阅读(394) 评论(0) 推荐(1) 编辑
摘要: Heapsort is acomparison-based sorting algorithm, and is part of the selection sort family. Although somewhat slower in practice on most machines than a good implementation ofquicksort, it has the adva... 阅读全文
posted @ 2009-11-03 17:09 lantionzy 阅读(469) 评论(0) 推荐(1) 编辑
摘要: Selection sort is also asorting algorithm, specifically anin-place comparisonsort. It has O(n2) complexity, making it inefficient on large lists, and generally performs worse than the similarinsertion... 阅读全文
posted @ 2009-11-03 16:35 lantionzy 阅读(257) 评论(0) 推荐(1) 编辑
摘要: Insertion sort is a simple sorting algorithm, a comparison sort in which the sorted array (or list) is built one entry at a time. It is much less efficient on large lists than more advanced algorithms... 阅读全文
posted @ 2009-11-03 16:21 lantionzy 阅读(297) 评论(0) 推荐(1) 编辑
摘要: Here are two strings, my task is to compare these two str1 and str2, and get if the occurences of each character of them are equal.  As we know, we can get the ASCII code of a character, so I use an a... 阅读全文
posted @ 2009-11-03 15:26 lantionzy 阅读(378) 评论(0) 推荐(1) 编辑
摘要: Here is a way to find the k-th largest number from an ayyay based on the theory of quick sort with an algorithmic complexity of O(n).  First we find a base element from the array randomly, and then re... 阅读全文
posted @ 2009-11-03 14:31 lantionzy 阅读(652) 评论(0) 推荐(1) 编辑
摘要: The quick sort is an in-place, divide-and-conquer, massively recursive sort. Typically, quicksort is significantly faster in practice than other Θ(nlogn) algorithms, because its inner loop can be... 阅读全文
posted @ 2009-11-03 13:26 lantionzy 阅读(344) 评论(0) 推荐(1) 编辑
摘要: The bubble sort is the oldest and simplest sort in use. Unfortunately, it's also the slowest.   The bubble sort works by comparing each item in the list with the item next to it, and swapping them if ... 阅读全文
posted @ 2009-11-03 10:32 lantionzy 阅读(372) 评论(1) 推荐(1) 编辑