归并排序(merge sort)是一个时间复杂度为O(nlogn)的基于比较的排序算法(comparison based sorting algorithm)。 归并排序大多数实现(implementation)都将其实现成了一个stable sort, 所谓的stable sort的意思就是the implementation preserves the input order of equal...
分类:
编程语言 时间:
2014-07-28 15:55:43
阅读次数:
392
Equal 和==比较因为值类型是存储在内存中的堆栈(以后简称栈),而引用类型的变量在栈中仅仅是存储引用类型变量的地址,而其本身则存储在堆中。"==" : 操作比较的是两个变量的值是否相等,对于引用型变量表示的是两个变量在堆中存储的地址是否相同,即栈中的内容是否相同."equals" : 操作表示的...
分类:
其他好文 时间:
2014-07-25 14:10:11
阅读次数:
223
1. 函数模板
函数模板是一个独立于类型的函数,可作为一种方式,产生函数的特定类型版本。
// implement strcmp-like generic compare function
// returns 0 if thevalues are equal, 1 if v1 is larger, -1 if v1 is smaller
template typename...
分类:
编程语言 时间:
2014-07-23 21:00:05
阅读次数:
279
ForwardIterlower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, last)中的第一个大于等于值val的位置。 ForwardIter upper_bound(Forward...
分类:
其他好文 时间:
2014-07-23 16:17:51
阅读次数:
323
题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve t....
分类:
编程语言 时间:
2014-07-23 12:27:46
阅读次数:
290
http://acm.hdu.edu.cn/showproblem.php?pid=3280用了简单的枚举。Equal Sum PartitionsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Othe...
分类:
其他好文 时间:
2014-07-22 22:48:13
阅读次数:
218
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:
其他好文 时间:
2014-07-21 14:35:26
阅读次数:
206
Partition ListGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should pres...
分类:
其他好文 时间:
2014-07-21 08:28:54
阅读次数:
230
equal_range(应用于有序区间)
--------------------------------------------------------------------------------------------------------------------------------------
描述:利用二分查找找到一个区间,区间里的所有值都等于给定值,返回的是一个pair,
分别存储区间的上界迭代器和下界迭代器
源码:
template <class ForwardIterator, c...
分类:
其他好文 时间:
2014-07-20 23:06:36
阅读次数:
263
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
比较两个...
分类:
编程语言 时间:
2014-07-20 22:12:03
阅读次数:
273