数据结构
翟小花@@
这个作者很懒,什么都没留下…
展开
-
链表
#include "stdio.h" #include "string.h"#include "ctype.h" #include "stdlib.h" #include "io.h" #include "math.h" #include "time.h"#define OK 1#define ERROR 0#define TRUE 1#define ...原创 2019-12-07 23:41:45 · 69 阅读 · 0 评论 -
左右子树互换
myNode *transform(myNode *root){ if(root!=NULL) { root->rchild=transform(root->rchild); root->lchild=transform(root->lchild); myNode *temp; temp=ro...转载 2019-12-07 21:37:49 · 398 阅读 · 0 评论 -
降序sort
#include <iostream>#include <algorithm>using namespace std;int main() { int arr[] = { 2, 4, 5, 3, 1 }; sort(arr, arr + 5, greater<int>()); for(int i = 0;i < 5;i++){...转载 2019-12-07 19:38:08 · 83 阅读 · 0 评论 -
完全二叉搜索树
#include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;int num[1001];int ans[1001];int n;int cnt;int flag=0;void print(){ ...原创 2019-12-07 19:30:33 · 169 阅读 · 0 评论 -
先序输出叶子节点
void PreorderPrintLeaves( BinTree BT ){ if(BT!=NULL) { if(BT->Left==NULL&&BT->Right==NULL) printf("data"); else { PreorderPrintLe...原创 2019-12-07 18:48:06 · 169 阅读 · 0 评论 -
树的遍历
void InorderTraversal( BinTree BT )//中序遍历{ if(BT) { InorderTraversal(BT->left); printf("%c",BT->Data); InorderTraversal(BT->right); }}void PreorderTrave...原创 2019-12-07 18:37:43 · 83 阅读 · 0 评论 -
求树的高度
int Getheight(BinTree BT){ int x1,int x2; if(BT==NULL) return 0; else { x1= Getheight(BT->left); x2= Getheight(BT->right); if(x1>x2) ...原创 2019-12-07 18:08:14 · 155 阅读 · 0 评论 -
7-2 堆栈操作合法性 (20 分)
假设以S和X分别表示入栈和出栈操作。如果根据一个仅由S和X构成的序列,对一个空堆栈进行操作,相应操作均可行(如没有出现删除时栈空)且最后状态也是栈空,则称该序列是合法的堆栈操作序列。请编写程序,输入S和X序列,判断该序列是否合法。输入格式:输入第一行给出两个正整数N和M,其中N是待测序列的个数,M(≤50)是堆栈的最大容量。随后N行,每行中给出一个仅由S和X构成的序列。序列保证不为空,且长度...原创 2019-11-03 16:58:02 · 1236 阅读 · 0 评论 -
PTA栈和队列判断
1-1通过对堆栈S操作:Push(S,1), Push(S,2), Pop(S), Push(S,3), Pop(S), Pop(S)。输出的序列为:123。 (2分)F1-2若一个栈的输入序列为1,2,3,…,N,输出序列的第一个元素是i,则第j个输出元素是j−i−1。 (2分)F1-3若一个栈的输入序列为{1, 2, 3, 4, 5},则不可能得到{3, 4, 1, 2, 5}这...原创 2019-09-29 16:41:14 · 508 阅读 · 0 评论 -
数据结构--顺序表
原创 2019-09-22 09:59:05 · 87 阅读 · 0 评论 -
数据结构--绪论作业
原创 2019-09-22 09:51:39 · 164 阅读 · 0 评论