![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Algorithms
vmxplus
这个作者很懒,什么都没留下…
展开
-
Algs4-1.4.22斐波那契查找算法(Fibonacci Search)Java 实现
Code of Fiboonacci Search原创 2015-05-19 15:37:07 · 1019 阅读 · 0 评论 -
Algs4-1.4.18 Find local minimum in n x n matrix in O(n) time
Question:You are given an n by n grid of distinct numbers. A number is a local minimum if it is smaller than all of its neighbors. (A neighbor of a number is one immediately above, below, to the l转载 2015-05-18 16:21:11 · 2127 阅读 · 0 评论 -
Algs4-2.2.2 归并算法为EASYQUESTION排序的轨迹
Merge Sort (Top Down) Code:package sed.algorithm.chapter2.section2;import edu.princeton.cs.introcs.StdOut;public class Merge { private static Comparable[] aux; public static void sort(Comparable原创 2015-06-17 20:54:24 · 445 阅读 · 0 评论 -
Algs4-1.4.34热还是冷-猜出秘密数(Hot or Cold guess a secret integer)
Question: 热还是冷。你的目标是猜出1到N之间的一个秘密整数。每次猜完一个整数后,你会知道你的猜测和这个秘密整数是否相等(如果是则游戏结束)。如果不相等,你会知道你的猜测相比上一次猜测距离该秘密整数是比较热(近)还是比较冷(远离)。Answer: 假设你知道秘密数在区间[a,b]上,且最后一次猜的数值为c。 你希望将区间一分为二,这样就可以知道该数是在[a,m]上还是在翻译 2015-05-20 19:40:34 · 1015 阅读 · 0 评论 -
Algs4 union-find算法 带路径压缩的加权Quick-Union实现
This is a union find algorithm原创 2015-05-30 19:28:10 · 1389 阅读 · 2 评论 -
Algs4-2.2.11 改进的Merge排序
Problem:对归并排序做如下优化: - 加快小数组排序 - 检测数组是否已经有序 - 通过在递归中交换参数避免数组复制。package sed.algorithm.chapter2.section2;import edu.princeton.cs.introcs.StdOut;import edu.princeton.cs.introcs.StdRandom;public cla原创 2015-06-23 14:58:06 · 528 阅读 · 0 评论 -
Algs4-2.2.17链表归并排序
Description归并排序是链表排序的最佳方法,因为它不需要额外的空间,且运行时间是线性对数级别的。 这里的代码是从网页:http://www.dontforgettothink.com/2011/11/23/merge-sort-of-linked-list/ 拷贝来的。这里要谢谢原作者Codeprivate class Node { Comparable info;转载 2015-06-25 13:10:40 · 422 阅读 · 0 评论