随笔分类 - 算法Sedgewick第四版
摘要:一、 1.特点 (1)The quicksort algorithm’s desirable features are that it is in-place (uses only a small auxiliary stack) and thatit requires time proportio
阅读全文
摘要:一、 1. 2.
阅读全文
摘要:一、 1. 2. 3. 二、代码
阅读全文
摘要:一、 1.特点 (1)merge-sort : to sort an array, divide it into two halves, sort the two halves (recursively), and then merge the results. As you will see, o
阅读全文
摘要:用二分查找法改进
阅读全文
摘要:一、介绍 1.希尔排序的思路:希尔排序是插入排序的改进。当输入的数据,顺序是很乱时,插入排序会产生大量的交换元素的操作,比如array[n]的最小的元素在最后,则要经过n-1次交换才能排到第一位,因为插入排序元素只能一位一位地交换。基于插入排序的这个缺点,希尔排序是以一个区间来的交换元素,然后不断缩
阅读全文
摘要:一、介绍 1. 2. 二、代码 1. 2. 3. 4.
阅读全文
摘要:一、介绍 1.时间和空间复杂度 运行过程 2.特点: (1)对于已排序或接近排好的数据,速度很快 (2)对于部分排好序的输入,速度快 二、代码
阅读全文
摘要:一、介绍 1.算法的时间和空间间复杂度 2.特点 Running time is insensitive to input. The process of finding the smallest item on onepass through the array does not give muc
阅读全文
摘要:Given an array a[] of N real numbers, design a linear-time algorithm to find the maximum value of a[j] - a[i] where j ≥ i.
阅读全文
摘要:1. 2. 3.
阅读全文
摘要:1 package algorithms.analysis14; 2 3 import algorithms.util.StdOut; 4 import algorithms.util.StdRandom; 5 6 /****************************************************************************** ...
阅读全文
摘要:1. 2.
阅读全文
摘要:1. 2. 3.字符串
阅读全文
摘要:1. 2. 3. 4. 5. 6.
阅读全文
摘要:1. The answer to this question is that we have discussed and used two classic algorithms,mergesort and binary search, have introduced the facts that t
阅读全文
摘要:For many programs, developing a mathematical model of running timereduces to the following steps:■Develop an input model, including a definition of th
阅读全文
摘要:1 package algorithms.util; 2 3 /****************************************************************************** 4 * Compilation: javac Directory.java 5 * Execution: java Directory dire...
阅读全文
摘要:1 /****************************************************************************** 2 * Compilation: javac MM1Queue.java 3 * Execution: java MM1Queue lambda mu 4 * Dependencies: Queue.j...
阅读全文