- 博客(16)
- 资源 (1)
- 收藏
- 关注
原创 快速排序代码
快速排序代码,同上一篇堆排序,更喜欢简洁代码,适合IT公司笔试面试用。 int partition(int a[], int low, int high){ int key = a[low]; while(low < high){ while( low < high && key <= a[high] ) high--; a[low] = a[high]; while(
2015-09-01 20:35:38
918
原创 堆排序代码
堆排序代码,比较喜欢简洁的代码,发现网上找到的堆排序代码太冗长了,现在整理一下,适合IT公司笔试面试用。void swap(int& a, int& b){ a = a ^ b; b = a ^ b; a = a ^ b; } void HeapAdjust(int arr[],int root, int size){ while(2 * root + 1 < size){
2015-09-01 20:32:10
560
原创 二叉树前/中/后序遍历非递归实现(用栈实现)LeetCode Binary Tree Traversal
在数据结构中,二叉树是常用的一种数据结构,而对二叉树进行遍历也是这种很常用的操作,遍历二叉树是我们可以使用递归的方法,代码很简单,但是每次调用递归函数都会都系统消耗比较大,下面介绍一下用栈的方法实现二叉树的遍历,例子为LeetCode里面的题目。 首先是LeetCode中已经定义好的二叉树结点 /** * Definition for binary tree * struct TreeNo
2015-04-02 16:28:32
832
原创 由先序遍历/后序遍历以及中序遍历重构二叉树
我们知道在二叉树的遍历中,如果知道了二叉树的先序遍历顺序和中序遍历顺序,或者后序遍历顺序和中序遍历顺序,都可以唯一确定一棵二叉树,而不知道中序遍历顺序,只知道前序遍历的和后序遍历的顺序,是不能唯一确定一棵二叉树的。例如,我们如果知道一棵二叉树的前序遍历顺序为“a d b g c e f h”,后序遍历为"g b d e h f c a",则我们可以得到如下的两棵二叉树(可能还有其他类型的二叉树)
2014-11-27 16:18:10
962
原创 1081. Rational Sum (20)
1081. Rational Sum (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given N rational numbers in the form "numerat
2014-11-25 20:33:17
940
原创 求最大公约数和最小公倍数(递归算法及非递归算法)
最近做题目发现一些题目需要求数的最大公约数和最小公倍数,想想最大公约数和最小公倍数平时做数学的时候感觉不是很难,但是突然要编程来实现,却一下子不知所措了,后来看了下别人写的,发现其实也不算特别难。最小公倍数其实只要一个公式,即整数A和整数B的最小公倍数为A*B/gcd(A,B)(gcd(A,B)为A和B的最大公约数),可见A和B的最小公倍数就为A和B的乘积再除以它俩的最大公约数,也就是说最终还是要
2014-11-25 19:59:01
12060
原创 1084. Broken Keyboard (20)
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a broken keyboard, some of the keys are
2014-11-25 15:42:41
507
原创 1024. Palindromic Number (25)
1024. Palindromic Number (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A number that will be the same when it is written forwa
2014-11-17 19:44:35
738
原创 1025. PAT Ranking (25)
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programming Ability Test (PAT) is organized by the College of
2014-11-17 10:43:29
461
原创 1009. Product of Polynomials (25)
1009. Product of Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to find A*B where A and
2014-11-16 16:46:36
550
原创 1002. A+B for Polynomials (25)
1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to find A+B where A and B
2014-11-16 15:47:26
509
原创 1008. Elevator (20)
1008. Elevator (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest building in our city has only one elevator. A request
2014-11-16 10:08:02
444
原创 1006. Sign In and Sign Out (25)
1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue At the beginning of every day, the first person who s
2014-11-16 09:37:34
536
原创 1007. Maximum Subsequence Sum (25)
1007. Maximum Subsequence Sum (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a sequence of K integers { N1, N2, ..., NK }
2014-11-15 10:36:41
568
原创 1005. Spell It Right (20)
1005. Spell It Right (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a non-negative integer N, your task is to compute the
2014-11-15 10:16:23
465
opencv 2.2以前版本的CvvImage.h和CvvImage.cpp
2014-11-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅