摘要: package chap08_Linear_Time_Sort;import static org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;public class CopyOfSortAlgorithms { /** * 基数排序 * * @param n * @par... 阅读全文
posted @ 2014-06-11 12:27 JintaoXIAO 阅读(114) 评论(0) 推荐(0) 编辑
摘要: package chap08_Linear_Time_Sort;import static org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;public class SortAlgorithms { /** * 计数排序算法 maxvalue为数组中的最大值 * * @param... 阅读全文
posted @ 2014-06-10 22:01 JintaoXIAO 阅读(221) 评论(0) 推荐(0) 编辑
摘要: package chap07_Quick_Sort;import static org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;public class SortAlgorithms { /** * 快速排序算法 * * @param n */ static voi... 阅读全文
posted @ 2014-06-10 19:17 JintaoXIAO 阅读(162) 评论(0) 推荐(0) 编辑
摘要: package chap06_Heap_Sort;import static org.junit.Assert.*;import java.util.ArrayList;import java.util.Arrays;import org.junit.Test;/** * 优先队列,二叉堆数组实现,数组的size最好大一些,至少比里面的堆大一些,来实现堆的扩展(插入元素) * *... 阅读全文
posted @ 2014-06-10 12:48 JintaoXIAO 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 以后尽量能用迭代就别用递归啊,递归只是让自己轻松了,但是却增加了电脑的负担。 package chap06_Heap_Sort;import static org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;public class SortAlorithms { /** * 返回当前下标下父节点的... 阅读全文
posted @ 2014-06-09 23:03 JintaoXIAO 阅读(171) 评论(0) 推荐(0) 编辑
摘要: package chap04_Divide_And_Conquer;import static org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;/** * 矩阵相乘的算法 * * @author xiaojintao... 阅读全文
posted @ 2014-06-08 16:48 JintaoXIAO 阅读(432) 评论(0) 推荐(0) 编辑
摘要: /** * 获得连续子数组的最大和 * * @author dfeng * */ private static long getMax(long a, long b) { return a > b ? a : b; } /** * 获得连续子数组的最大和 * * @param array ... 阅读全文
posted @ 2014-06-07 16:55 JintaoXIAO 阅读(267) 评论(0) 推荐(0) 编辑
摘要: /** * 最大子数组的暴力求解算法,复杂度为o(n2) * @param n * @return */ static MaxSubarray findMaxSubarraySlower(int[] n) { long tempSum = 0; int left = 0; int right = 0; ... 阅读全文
posted @ 2014-06-07 16:02 JintaoXIAO 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 原来不是减治法啊,也算一种新方法了。时间复杂度也是O(n)了。应该是O(3n)package chap04_Divide_And_Conquer;import static org.junit.Assert.*;import java.util.Arrays;import org.junit.Tes... 阅读全文
posted @ 2014-06-06 22:04 JintaoXIAO 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 1 package chap02; 2 3 import static org.junit.Assert.*; 4 5 import java.util.Arrays; 6 7 import org.junit.Test; 8 9 public class ques2_4... 阅读全文
posted @ 2014-06-05 13:00 JintaoXIAO 阅读(334) 评论(0) 推荐(0) 编辑