摘要: 1 public class BinarySearch{ 2 public int BinarySearch(int[] array, int target){ 3 if(array == null || array.length = 0){ 4 return -1; 5 } 6 while (left ... 阅读全文
posted @ 2018-04-03 08:40 小粉要努力呀 阅读(44) 评论(0) 推荐(0) 编辑
摘要: 1 public class Power{ 2 public long power(int a, int b){ 3 if (b == 0){ 4 return 1; 5 } 6 if (a == 0) { 7 return 0; 8 } 9 10 ... 阅读全文
posted @ 2018-04-03 08:26 小粉要努力呀 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 1 public class Fibonacci{ 2 3 4 public long fibonacci(int k) { 5 if (int k <= 0) { 6 return 0; 7 } 8 long[] array = new long[k + 1]; 9 array[1]... 阅读全文
posted @ 2018-04-03 08:19 小粉要努力呀 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 1 public class QuickSort { 2 Random rand = new Random(); 3 public int[] quickSort(int[] array) { 4 if (array == null || array.length = 0) { 5 return array; 6 ... 阅读全文
posted @ 2018-04-03 07:57 小粉要努力呀 阅读(73) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, sort the elements in the array in ascending order. The selection sort algorithm should be used to solve this problem. Exam 阅读全文
posted @ 2018-04-03 07:04 小粉要努力呀 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Sort 的时间复杂度:o(n), 空间复杂度 o(logn)。 Merge 的时间复杂度: o(nlogn), 空间复杂度 o(n)。 总时间复杂度:o(nlogn) 总空间复杂度:o(n)。 阅读全文
posted @ 2018-03-07 05:43 小粉要努力呀 阅读(96) 评论(0) 推荐(0) 编辑