2016年1月22日

Vector and ArrayList in Java

摘要: Internally, both classes use array. Vector by default double the array size when array is full, while ArrayList increases the array size by 50%.Vector... 阅读全文

posted @ 2016-01-22 13:51 touchdown 阅读(109) 评论(0) 推荐(0)

2016年1月21日

递推,贪心,动态规划

摘要: DP——“下一步最优是从当前最优得到的”。最优可以是“longest", "shortest"等等。贪心——为了计算最终的最优解,需要计算当前的最优解递推——类似于斐波那契序列作者:王勐链接:http://www.zhihu.com/question/23995189/answer/35429905... 阅读全文

posted @ 2016-01-21 10:56 touchdown 阅读(166) 评论(0) 推荐(0)

复杂度分析

摘要: 空间复杂度就是为了支持你的计算所必需存储的状态最多有多少,时间复杂度就是从初始状态到达最终状态中间需要多少步。 阅读全文

posted @ 2016-01-21 10:48 touchdown 阅读(98) 评论(0) 推荐(0)

2016年1月20日

BST: when to use i <= j or i < j

摘要: i seq, int target){ int lo = 0; int hi = seq.size() - 1; while(lo < hi) { int mid = lo + (hi - lo) / 2; if(seq.get(mid) < t... 阅读全文

posted @ 2016-01-20 22:20 touchdown 阅读(119) 评论(0) 推荐(0)

2016年1月19日

Interface VS Abstract Class

摘要: An abstract class can have shared state or functionality. An interface is only a promise to provide the state or functionality. A good abstract class ... 阅读全文

posted @ 2016-01-19 23:34 touchdown 阅读(179) 评论(0) 推荐(0)

HashMap VS BST

摘要: HashMap usually performs search operations bounded with complexity of O(1)<=T(n)<=O(n). BST performs search operations in O(logN)<=T(n)<=O(N).HashMap ... 阅读全文

posted @ 2016-01-19 22:37 touchdown 阅读(192) 评论(0) 推荐(0)

vector VS list in C++

摘要: vector is like ArrayList in Java.vector:Continuous memory.Underlying array implementation.Pre-allocate space for future element. This means extra spac... 阅读全文

posted @ 2016-01-19 16:04 touchdown 阅读(169) 评论(0) 推荐(0)

Java ArrayList构造分析

摘要: 1 /** 2 * The array buffer into which the elements of the ArrayList are stored. 3 * The capacity of the ArrayList is the length of this... 阅读全文

posted @ 2016-01-19 15:05 touchdown 阅读(403) 评论(0) 推荐(0)

导航