
C/C++
文章平均质量分 74
朝暾夕月
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
对动态数组进行快速排序
#include #include #include void swap(int&,int&); int partion(int *a,int p,int r); void QuickSort(int *a,int p,int r); int main() { int *array1 = 0, num, i; printf("please input the原创 2013-09-07 17:20:37 · 801 阅读 · 0 评论 -
在online judge中建立简单数据结构,简单高效处理
建立简单的数据结构并进行后续处理 例如:判断两序列是否为同一二叉搜索树序列 输入: 开始一个数n,(1 接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。 接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。 输出: 如果序列相同则输出YES,否则转载 2015-04-24 23:22:45 · 464 阅读 · 0 评论 -
二叉排序树的相关操作(插入,查找,删除,遍历等)
#ifndef _NODEBITREE_H #define _NODEBITREE_H #include class NodeBitree{ public: NodeBitree(int key,NodeBitree *lchild=NULL,NodeBitree *rchild=NULL):key(key),lchild(lchild),rchild(rchild){} //NodeBitr原创 2015-04-06 20:35:18 · 537 阅读 · 0 评论 -
二叉排序树关于删除节点的方法(对上一博客的补充)
bool SortedBitree::DeleteBST(NodeBitree *&root,const int data){ NodeBitree *index=NULL; if(NULL==root){ std::cout<<"Empty Tree or not found"<<std::endl; return false; }else{ if(root->getdata(原创 2015-04-06 21:06:50 · 519 阅读 · 0 评论 -
红黑树的实现
红黑树(Red Black Tree) 是一种自平衡二叉查找树,是在计算机科学中用到的一种数据结构,典型的用途是实现关联数组。 红黑树的五条性质:(特别重要) 1.节点是红色或黑色 2.根节点是黑色 3. 每个叶节点(NIL节点,空节点)是黑色的,又称为外节点 4.如果一个节点是红色的,则他的两个子节点都是黑色的 5.对每个节点,从该节点到其所有后代叶节点的简单路径上,均包含相同数目的原创 2015-04-11 23:49:52 · 397 阅读 · 0 评论 -
堆排序
堆排序(Heapsort)是指利用堆这种数据结构所设计的一种排序算法。堆积是一个近似完全二叉树的结构,并同时满足堆积的性质:即子结点的键值或索引总是小于(或者大于)它的父节点。 子节点总是小于其父节点的堆结构称为最大堆(MaxHeap) 子节点总是大于其父节点的堆结构称为最小堆(MinHeap) 堆排序分二部分: 1.建立堆结构 2.堆排序(包含最大或最小堆的维护) 首先说明一下最大堆原创 2015-04-18 14:11:24 · 380 阅读 · 0 评论 -
2011年浙江大学计算机及软件工程研究生机试真题
题目描述: This time, you are supposed to find A+B where A and B are two matrices, and then count the number of zero rows and columns. 输入: The input consists of several test cases, each原创 2015-04-04 14:05:27 · 589 阅读 · 0 评论 -
C++ 容器(vector)算法:判断某数是否为素数(范围为1~10000)
1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int main(){ 7 int a; 8 vectorprim(10000,1); 9 for(int i=2;i 10 for(int j=i;j 11原创 2013-10-01 21:42:56 · 715 阅读 · 0 评论 -
冒泡算法对动态数组排序
#include #include #include void swap(int&,int&); void sort(int* ,int n); int main() { int *array1 = 0, num, i; printf("please input the number of element: "); scanf("%d", &nu原创 2013-09-07 16:28:38 · 558 阅读 · 0 评论 -
对动态数组用 选择排序算法排序(C语言)
#include #include #include void swap(int&,int&); void sort(int* ,int n); int main() { int *array1 = 0, num, i; printf("please input the number of element: "); scanf("%d", &nu原创 2013-09-07 16:09:08 · 1178 阅读 · 0 评论 -
01背包问题的一点说明
01背包问题的一点说明1.动态规划 动态规划(英语:Dynamic programming,简称DP)是一种在数学、计算机科学和经济学中使用的,通过把原问题分解为相对简单的子问题的方式求解复杂问题的方法。动态规划常常适用于有重叠子问题[1]和最优子结构性质的问题,动态规划方法所耗时间往往远少于朴素解法。动态规划背后的基本思想非常简单。大致上,若要解一个给定问题,我们需要解其不同部分(即子问题),原创 2015-05-10 22:59:17 · 689 阅读 · 0 评论