随笔分类 -  Algorithm Backup

Algorithm backup ---- Merge Sort(归并排序算法)
摘要: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 阅读(432) 评论(0) 推荐(1)
Algorithm backup ---- Heap Sort(堆排序算法)
摘要: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 阅读(476) 评论(0) 推荐(1)
Algorithm backup ---- Selection sort(选择排序算法)
摘要: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 阅读(262) 评论(0) 推荐(1)
Algorithm backup ---- Insertion Sort(插入排序算法)
摘要: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 阅读(306) 评论(0) 推荐(1)
Algorithm backup ---- Compare occurences of each character of two strings(比较两个字符串每个字符出现频率是否一样)
摘要: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 阅读(386) 评论(0) 推荐(1)
Algorithm backup ---- Find the kth largest number(寻找第K大数)
摘要: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 阅读(667) 评论(0) 推荐(1)
Algorithm backup ---- Quick Sort(快速排序算法)
摘要: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 阅读(356) 评论(0) 推荐(1)
Algorithm backup ---- Bubble Sort(冒泡排序算法)
摘要: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 阅读(389) 评论(1) 推荐(1)