- 博客(15)
- 收藏
- 关注
原创 判断二叉树是否为二叉排序树
#include <iostream>#include <stack>#include <queue>#include<limits.h>using namespace std;#define MINKEY INT_MIN //关键字的下限class Treenode{public: int dat...
2019-05-08 10:46:08
1435
原创 根据先序和中序序列建立二叉树
#include <iostream>#include <stack>#include <queue>using namespace std;class Treenode{public: char data; Treenode * lchild; Treenode * rchild;};typedef struct Tr...
2019-04-15 23:46:42
570
原创 浙大数据结构--层次遍历输出树的叶子节点
Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.Input Specification:Each input file contains one test case. For each case, the first line gives a ...
2019-04-03 18:30:56
608
原创 浙大数据结构 树的同构
03-树1 树的同构 (25 分)给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。图1图2现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树...
2019-04-02 16:03:22
394
原创 浙大数据结构02-线性结构4 Pop Sequence (25 分)
02-线性结构4 Pop Sequence (25 分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers i...
2019-03-26 15:31:42
524
原创 PTA 数据结构 倒置链表( 数组存储节点,创建链表。)
02-线性结构3 Reversing Linked List (25 分)Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, th...
2019-03-18 11:11:10
328
原创 PTA数据结构--------设计函数分别求两个一元多项式的乘积与和。
02-线性结构2 一元多项式的乘法与加法运算 (20 分)设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。...
2019-03-15 21:22:39
10834
原创 两个有序链表合并成一个非递减的链表函数
List Merge(List L1,List L2){ List p1=L1->Next; List p2=L2->Next; List L = (List)malloc(sizeof(struct Node)); List p=L; while(p1!=NULL&&p2!=NULL){ if(p1->D...
2019-03-13 17:12:20
1178
原创 两个顺序表求交集-----优化算法
2.11//版权所有贾涛//解题关键:有序数组,两个指针分别指向数组第一个元素,比较,相等的存入新表中#include <iostream>#include<math.h>#include<stdlib.h>using namespace std;class List{ int Maxsize,last; ...
2019-03-07 18:10:14
2292
原创 奇偶排序
2.10//版权所有贾涛//解题关键建立新数组#include <iostream>#include<math.h>#include<stdlib.h>using namespace std;class List{ int Maxsize,last; //last�Ƕ�̬�...
2019-03-07 18:06:05
7838
原创 顺序表特定元素的删除
2.09学习到两点:++i和i++的区别;用一个从零起++的变量可优化二重循环;//版权所有贾涛#include <iostream>#include<math.h>#include<stdlib.h>using namespace std;class List{ int Maxsize,last; ...
2019-03-07 18:02:13
680
原创 PAT甲级1001 这个题我也是醉了 只能暴力了
#include <iostream>#include<math.h>#include<stdlib.h>using namespace std;void sum(int a,int b){ int ans=a+b; int remainder,core,remainder2; if((abs(ans)>=0)&...
2019-03-06 17:24:47
291
原创 PTA数据结构求最大子列和且输出子列首尾整数-----动态规划
动态规划方程:dp[i]=dp[i-1]+A[i];边界条件dp[0]=A[0]#include <iostream>#include<stdlib.h>#include<string.h>#include<math.h>using namespace std;#define Max 10000int A[Max...
2019-03-05 23:26:08
306
原创 PTA数据结构-求最大连续子列和(在线处理法)
#include <iostream>using namespace std; void maxsum(int a[],int k){ int Maxsum=0; int thissum=0; for(int i=0;i<k;i++){ thissum=thissum+a[i]; if(thissum>Maxs...
2019-03-05 20:16:54
374
原创 获取积分
获取积分基本规则如下:1、一天内登录过博客获得1分;2、一天内发表过文章获得2分;3、一天内发表过评论获得2分。注:给自己评论和回复评论不获得积分;升级期间,新版博客用户在旧版博客中发表的评论不获得积分。什么是博客等级,如何获得等级?等级是用户在新浪博客中影响力的综合体现。现在的等级暂由个人博客的访问量转换而来,访问量大的用户级别就会越高。提高等级的方法:随着您博客访问量的提高,
2017-07-14 16:25:46
903
12
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅