自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(34)
  • 收藏
  • 关注

转载 (HW)CoinsCombination(Java)

1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Vector<Integer> v = new Vector<>(); 6 v.add(1); 7 v.add(2); 8 ...

2019-06-04 18:57:00 156

转载 (HW)Combination(Java)

1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Vector<Integer> v = new Vector<>(); 6 for(int i = 1; i <= 5; i++) 7 ...

2019-06-04 14:36:00 145

转载 (HW)Permutation(Java)

1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Vector<Integer> v = new Vector<>(); 6 for(int i = 1; i <= 5; i++) 7 ...

2019-05-31 21:47:00 148

转载 (HW)rod cutting(Java)

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 //第一个位置不...

2019-05-31 20:08:00 128

转载 (HW)uniquePath_2(障碍物)(Java)

1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Scanner input = new Scanner(System.in); 6 int m = input.nextInt(); 7 int n = ...

2019-05-28 20:37:00 226

转载 (HW)uniquePath(Java)

1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Scanner input = new Scanner(System.in); 6 int m = input.nextInt(); 7 int n = ...

2019-05-28 19:23:00 137

转载 (HW)爬楼梯(Java)

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 = ...

2019-05-26 16:56:00 135

转载 最大连续子列和问题(Java)

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...

2019-05-25 20:48:00 144

转载 (HW)Dijkstra算法(Java)

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; ...

2019-05-18 19:59:00 129

转载 最小堆的基础操作(Java)

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 ...

2019-05-16 12:42:00 318

转载 (HW)Prim算法(Java)

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; ...

2019-05-15 20:40:00 124

转载 (HW)DFS and BFS(Java)

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(S...

2019-05-15 08:55:00 114

转载 深度优先搜索(DFS)(Java)

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...

2019-05-05 21:40:00 282

转载 图的存储结构(Java)

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 publ...

2019-05-05 09:30:00 259

转载 二叉搜索树的基础操作(Java)

1 //1 二叉搜索树的判定 2 //method 1 利用中序遍历(最优解) 对于任一结点 若它后一个结点的值大于它的值 则为二叉搜索树 3 //时间复杂度: O(n) 空间复杂度: O(1) 4 public boolean isBST(BiTNode node) 5 { 6 if(node == null) 7   return tru...

2019-05-04 20:09:00 79

转载 二叉树的基础操作(Java)

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 = getD...

2019-05-04 11:58:00 145

转载 前序遍历构造已知二叉树(三叉链表实现)(Java)

1 public BiTNode createBiTree(BiTNode parent_node) 2 { 3 Scanner input = new Scanner(System.in); 4 int k = input.nextInt(); 5 if(k == -1) 6 return null; 7 8 ...

2019-05-04 11:52:00 389

转载 二叉树的遍历(非递归)

1 //二叉树的先序遍历(非递归) 2 public void PreOrderTraverse() 3 { 4 BiTNode p = this.root; 5 Stack stack = new Stack(10000); 6 7 while(!stack.isEmpty || p != null) 8   if(p...

2019-04-22 00:31:00 92

转载 前序遍历构造已知二叉树(二叉链表实现)(Java)

1 public BiTNode createBiTree() 2 { 3 Scanner input = new Scanner(System.in); 4 int k = input.nextInt(); 5 if(k == -1) 6 return null; 7 8 BiTNode...

2019-04-21 23:11:00 306

转载 使用栈实现队列(2)(Java)

1 class MyQueue 2 { 3 private Stack s1; 4 private Stack s2; 5 6 public MyQueue(int size) 7 { 8 this.s1 = new Stack(size); 9 this.s2 = new S...

2019-04-11 17:08:00 72

转载 使用栈实现队列(1)(Java)

1 class MyQueue 2 { 3 private Stack s1; 4 private Stack s2; 5 6 public MyQueue(int size) 7 { 8 this.s1 = new Stack(size); 9 this.s2 = new S...

2019-04-11 16:56:00 101

转载 使用队列实现栈(2)(Java)

1 class MyStack 2 { 3 private Queue q1; 4 private Queue q2; 5 6 public MyStack(int size) 7 { 8 this.q1 = new Queue(size); 9 this.q...

2019-04-11 16:12:00 122

转载 使用队列实现栈(1)(Java)

1 class MyStack 2 { 3 private Queue q1; 4 private Queue q2; 5 6 public MyStack(int size) 7 { 8 this.q1 = new Queue(size); 9 this.q...

2019-04-11 16:03:00 139

转载 队列的实现(Java)

1 class Queue 2 { 3 private int front; 4 private int rear; 5 private int[] a; 6 7 public Queue(int size) 8 { 9 this.front = this.rear = 0;...

2019-04-11 13:58:00 78

转载 栈的实现(Java)

1 class Stack 2 { 3 private int top; 4 private int[] a; 5 6 public Stack(int size) 7 { 8 this.top = -1; 9 this.a = new int[size];10 }...

2019-04-11 13:51:00 109

转载 Counting Sort(Java)

1 public static void countingsort(int[] a, int n) //n = a.length 2 { 3 int max = a[0], min = a[0]; 4 for(int i = 1; i < a.length; i++) 5 { 6 if(a[i] > max) 7 ...

2019-04-06 23:36:00 256

转载 Quick Sort(三向切分的快速排序)(Java)

1 //三向切分的快速排序 2 //这种切分方法对于数组中有大量重复元素的情况有比较大的性能提升 3 4 public static void main(String[] args) 5 { 6 Scanner input = new Scanner(System.in); 7 int n = input.nextInt(); 8 ...

2019-03-29 20:15:00 186

转载 heapsort(Java)(最小堆)

1 public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 7 a[0] = 0; //不使用第一个位置...

2019-03-25 16:52:00 131

转载 Quick Sort(Java)

1 public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 ...

2019-03-15 22:25:00 112

转载 Insertion Sort 与 Merge Sort的性能比较(Java)

1    public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 ...

2019-03-11 21:42:00 259

转载 Merge Sort(Java)

1    public static void main(String[] args) 2 { 3 Scanner input = new Scanner(System.in); 4 int n = input.nextInt(); 5 int[] a = new int[n]; 6 ...

2019-03-10 21:14:00 92

转载 Insertion Sort(Java)

1 //Insertion Sort 2 3 for(int i = 1; i < a.length; i++) 4 { 5 int key = a[i]; 6 int j; 7 for(j = i - 1; j >= 0 && a[j] > key; j--) 8 a[j + ...

2019-03-09 20:51:00 366

转载 Binary Search(Java)(递归)

1 public static int rank(int[] array, int k, int front, int rear) 2 { 3 if(front > rear) 4 return -1; 5 6 int mid = front + (rear - front) / 2; 7 ...

2019-03-09 14:42:00 180

转载 Binary Search(Java)(非递归)

1 public static int rank(int[] array, int k) 2 { 3 int front = 0, rear = array.length - 1; 4 5 while(front <= rear) //front = rear时, mid必与front和rear指向同一个元素 6 ...

2019-03-09 14:35:00 97

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除