前进的道路不是一帆风顺的,要随时迎接挑战,敢于战胜困难!

坚持一下,找人聊聊天,释放一些压力!

 

2010年8月11日

判断整数序列是不是二元查找树的后序遍历结果

摘要: #include <iostream>using namespace std;bool verifySquenceOfBST(int squence[], int length){if (squence==NULL||length<=0){return false;}int root=squence[length-1];int i=0;for(; i<length-1; +... 阅读全文

posted @ 2010-08-11 16:29 山径山精 阅读(248) 评论(0) 推荐(0) 编辑

查找最小的k个元素

摘要: 算法中使用到了堆,即stl中的multiset。#include <iostream>#include <vector>#include <set>using namespace std;typedef multiset<int, greater<int>> IntHeap;void FindKLeastNumbers(const vec... 阅读全文

posted @ 2010-08-11 15:25 山径山精 阅读(370) 评论(0) 推荐(0) 编辑

在二元树中查找和为某一值的所有路径

摘要: #include <iostream>#include <vector>using namespace std;struct BinaryTreeNode{int m_nValue;BinaryTreeNode* m_pLeft;BinaryTreeNode* m_pRight;};int count=0; //print controlvoid FindPath(Bina... 阅读全文

posted @ 2010-08-11 14:25 山径山精 阅读(254) 评论(0) 推荐(0) 编辑

求子数组的最大和

摘要: #include <iostream>using namespace std;bool FindGreatestSumOfSubArray(int *pData, unsigned int nLength, int &nGreatestSum){if (!pData||0==nLength){return false;}int nCurrentSum=nGreatestSum=... 阅读全文

posted @ 2010-08-11 13:34 山径山精 阅读(271) 评论(0) 推荐(0) 编辑

把二元查找树转变成排序的双向链表

摘要: #include <iostream>#include <time.h>#define MAX_NUM 10using namespace std;struct BSTreeNode {int m_nValue;BSTreeNode *m_pLeft;BSTreeNode *m_pRight;};int count=0;void AddTree(BSTreeNode** T... 阅读全文

posted @ 2010-08-11 12:59 山径山精 阅读(513) 评论(0) 推荐(0) 编辑

导航