上一页 1 ··· 9 10 11 12 13
摘要: Stack: LIFO, the Stack is a deprecated interface we should use Deque interface. The implementation can use LinkedList or array push, pop, peek, size() 阅读全文
posted @ 2018-02-20 23:07 davidnyc 阅读(138) 评论(0) 推荐(0)
摘要: queue: FIFO, Queue is interface, the implementation could be LinkedList or array offer, poll, peek, size() isEmpty() 阅读全文
posted @ 2018-02-20 22:59 davidnyc 阅读(97) 评论(0) 推荐(0)
摘要: 时间: o(n) 空间 o(1): 没有recursion, 只有当前一层的call stack sorting 如果是general sorting algo(1:不能对数组的性质加以限制) comparison based(2: sorting 只能通过两个数的比较来进行) , 最好的时间复杂度 阅读全文
posted @ 2018-02-20 08:08 davidnyc 阅读(196) 评论(0) 推荐(0)
摘要: 时间复杂度, 空间复杂度 average: nlogn : logn 层 每层 n 次排序 n n/2 n/2 n/4 n/4 n/4 n/4 worst: 每次取最大或者最小值 阅读全文
posted @ 2018-02-15 03:03 davidnyc 阅读(112) 评论(0) 推荐(0)
摘要: 1 public class MergeSort { 2 3 public static void sortIntegers(int[] array) { 4 // write your code here 5 if (array == null || array.length ==0 ) { 6 return ; ... 阅读全文
posted @ 2018-02-15 00:23 davidnyc 阅读(132) 评论(0) 推荐(0)
摘要: 1 /* 2 * 1: time complexity o(n^2) 3 * 2: good performance for items around 10-20: better than merge sort and quick sort 4 * 3: no extra space needed 5 * */ 6 public class SelectSort { 7 p... 阅读全文
posted @ 2018-02-14 23:04 davidnyc 阅读(171) 评论(0) 推荐(0)
上一页 1 ··· 9 10 11 12 13