摘要: 1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Scanner input = new Scanner(System.in); 6 int n = input.nextInt(); 7 int k = input.nextIn... 阅读全文
posted @ 2019-05-26 16:56 Huayra 阅读(300) 评论(0) 推荐(0)
摘要: 1 public class test 2 { 3 public static void main(String[] args) 4 { 5 int[] array = new int[] {13,-3,-25,20,-3,-16,-23,18,20,-7,12,-5,-22,15,-4,7}; 6 int max_sum = Inte... 阅读全文
posted @ 2019-05-25 20:48 Huayra 阅读(311) 评论(0) 推荐(0)
摘要: 1 import java.util.Comparator; 2 import java.util.HashMap; 3 import java.util.LinkedList; 4 import java.util.List; 5 import java.util.Map; 6 import java.util.PriorityQueue; 7 import jav... 阅读全文
posted @ 2019-05-18 19:59 Huayra 阅读(285) 评论(0) 推荐(0)
摘要: 1 public class test 2 { 3 public static void main(String[] args) 4 { 5 int[] array = new int[] {3,5,6,11,20,8,9,2,7}; 6 createMinimumHeap(array); 7 for(int valu... 阅读全文
posted @ 2019-05-16 12:42 Huayra 阅读(283) 评论(0) 推荐(0)
摘要: 1 import java.util.Comparator; 2 import java.util.HashMap; 3 import java.util.LinkedList; 4 import java.util.List; 5 import java.util.Map; 6 import java.util.PriorityQueue; 7 8 publi... 阅读全文
posted @ 2019-05-15 20:40 Huayra 阅读(244) 评论(0) 推荐(0)
摘要: 1 import java.util.HashMap; 2 import java.util.LinkedList; 3 import java.util.Queue; 4 import java.util.Stack; 5 6 public class task1 7 { 8 public static void main(String[] args)... 阅读全文
posted @ 2019-05-15 08:55 Huayra 阅读(248) 评论(0) 推荐(0)
摘要: 1 //1 使用邻接表 时间复杂度: O(n+e) 2 //递归 3 public void DFS(int v) 4 { 5 System.out.print(this.vexs[v].data + " "); 6 this.visited[v] = true; 7 8 for(ArcNode p = this.vexs[v].firs... 阅读全文
posted @ 2019-05-05 21:40 Huayra 阅读(2866) 评论(0) 推荐(0)
摘要: 1 //1 无向图的邻接矩阵实现 时间复杂度:O(n^2) 空间复杂度:O(n^2) 2 class Graph 3 { 4 public int[][] adjacencyMatrix; //邻接矩阵 5 public int vexnum; //边数 6 public int arcnum; //顶点数 7 public char[] ve... 阅读全文
posted @ 2019-05-05 09:30 Huayra 阅读(1066) 评论(0) 推荐(0)
摘要: 1 //1 二叉搜索树的判定 2 //method 1 利用中序遍历(最优解) 对于任一结点 若它后一个结点的值大于它的值 则为二叉搜索树 3 //时间复杂度: O(n) 空间复杂度: O(1) 4 public boolean isBST(BiTNode node) 5 { 6 if(node == null) 7 return true; 8 9 ... 阅读全文
posted @ 2019-05-04 20:09 Huayra 阅读(218) 评论(0) 推荐(0)
摘要: 1 //1 二叉树的深度(在后序遍历的基础上进行 时间复杂度: O(n)) (即左右子树的最大深度加1) 2 public int getDepth(BiTNode node) 3 { 4 if(node == null) 5 return 0; 6 7 int count1, count2; 8 count1 = getDepth(node.lc... 阅读全文
posted @ 2019-05-04 11:58 Huayra 阅读(321) 评论(0) 推荐(0)