- 博客(17)
- 资源 (9)
- 问答 (4)
- 收藏
- 关注
原创 面试题50:二叉树中两个节点的最低公共祖先
#include #include #include using namespace std;typedef struct BtNode{ int value; struct BtNode *lchild; struct BtNode *rchild;}BtNode, *Bitree;Bitree newBtNode(){ Bitree p = new BtNode
2016-05-31 20:24:29 1086
原创 得到二叉树中从根节点到树中某一节点的路径
#include #include #include using namespace std;typedef struct BtNode{ int value; struct BtNode *lchild; struct BtNode *rchild;}BtNode, *Bitree;Bitree newBtNode(){ Bitree p = new BtNode
2016-05-31 20:19:46 6582
原创 归并排序
#include using namespace std;int combineSort( int a[], int low, int high ){ int ret = 0; if( NULL == a || low > high ) { cout high" << endl; ret = -1; return ret; } if( low == high
2016-05-31 09:08:53 395
原创 面试题47:不用加减乘除做加法
#include using namespace std;int Add( int num1, int num2 ){ int sum = 0; int carry = 0; do { sum = num1 ^ num2; carry = ( num1 & num2 ) << 1; num1 = sum; num2 = carry; }while( num2
2016-05-30 19:58:22 494
原创 面试题32:从1到n整数中1出现的次数
#include #include #include using namespace std;// 参考《剑指offer 面试题32:从1到n整数中1出现的次数 P174》 int powerOfn( int n ) { int result = 1; int cnt = 1; while( cnt <= n ) { result *= 10; cnt+
2016-05-29 11:45:56 405
原创 面试题31:连续子数组的最大和
#include using namespace std;long long getMaxSum( int a[], int low, int high ){ long long max = -INT_MAX - 1; long long sum = 0; if( NULL == a || low > high ) { cout high" << endl; m
2016-05-29 11:42:13 430
原创 multiset的插入与删除
#include #include#include #include#include using namespace std;int main (){ typedef multiset > IntSet; IntSet myset; int myints[] = {75,23,65,42,23}; for( int i = 0; i < 5; i++ )
2016-05-28 21:34:55 6423
原创 面试题29:找出数组中出现次数超过一半的数字-基于partition函数以及分摊法
#include using namespace std; int partition( int a[], int low, int high ){ if( low >= high ) { return low; } int index = low - 1; for( int i = low, j = high; i < j; ++i ) { if( a[i
2016-05-28 20:43:33 665
原创 面试题27:二叉搜索树按中序遍历原地转换为双向链表
#include #include #include #include using namespace std;typedef struct BtNode{ char data; struct BtNode *lchild; struct BtNode *rchild;}BtNode, *Bitree;typedef struct Node{ Bitree p
2016-05-27 18:22:27 1796
原创 字符串的全排列
#include #include #include #include #include #include #include #include #include #include using namespace std;// 打印pSrc的所有排列,pSrc中字符各不相同void printAllSeq( int curLength, const char *pSrc,
2016-05-27 15:44:28 529
原创 面试题25:二叉树中和为某一个值的路径
#include #include #include #include #include #include #include #include #include #include using namespace std;typedef struct Node{ int data; struct Node *lchild; struct Node *rchild;
2016-05-27 13:53:55 419
原创 面试题21:包含min函数的栈,面试题22:判断某一序列是否是出栈序列
#include #include #include #include #include #include #include #include #include #include using namespace std;// 判断pOut是否是pIn的出栈序列bool isOutStackSeq( const char *pIn, const char *pOut )
2016-05-27 10:34:02 435
原创 n个元素进栈,输出所有出栈序列-卡特兰数-递归
#include #include #include #include #include #include #include #include #include #include using namespace std;void printAllOutStackSeq( queue inQueue, int n, stack st, queue out ){ if(
2016-05-26 17:46:03 8928
原创 大数乘法、大数加法实现
#include #include #include #include #include #include #include #include using namespace std;// 实现两个数的加法// 判断一个字符串是否为有效的数bool isValidNumber( const string &s ){ bool ret = true; int len
2016-05-26 14:22:04 708
原创 面试题12:打印1到最大的n位数-大数问题-递归实现多层循环
#include #include #include #include #include #include #include using namespace std;void printToMaxNdigits( int n ){ if( n < 1 ) { cout << "printToMaxNdigits func: err -1, n < 1 " << en
2016-05-26 08:47:39 899
原创 快速排序、求旋转数组最小数字
#include #include #include #include using namespace std;// 快速排序1void quickSort( int a[], int l, int r ){ if( l >= r ) { return; } int i = l; int j = r; int mid = ( l + r ) / 2; i
2016-05-25 16:46:00 453
转载 二叉树非递归遍历、层次遍历、高度、节点数
// 参考大神所写 http://blog.csdn.net/hackbuteer1/article/details/6583988#include #include #include #include using namespace std;typedef struct BtNode{ char data; struct BtNode *lchild; struct
2016-05-24 20:32:06 2672
Hadoop的Eclipse插件,MapReduce
2014-04-08
华科考研历年机试C语言实现_无题目只有代码实现_不完整
2014-03-26
TA创建的收藏夹 TA关注的收藏夹
TA关注的人