随笔分类 -  数据结构

摘要:题意:给你一颗二叉树上面的若干节点上的值(均为正数),判断从根到所有的给定的点的路径上的节点,是不是都有值,且只被赋值一次。思路:这题不难,主要是一些细节上的处理,学习一下。。#includeusing namespace std;#define inf 0x3f3f... 阅读全文
posted @ 2018-08-31 19:31 MCQ 阅读(234) 评论(0) 推荐(0)
摘要:题意:有一颗n个结点的带权的无向树, 在s结点放两个机器人, 这两个机器人会把树的每条边都走一遍, 但是最后机器人不要求回到出发点. 问你两个机器人走的路总长之和的最小值是多少?思路:考虑从一个结点遍历整个树再回到原点需要把每个边计算两遍,这里机器人不用回到出发点,所... 阅读全文
posted @ 2018-08-31 00:11 MCQ 阅读(172) 评论(0) 推荐(0)
摘要:具体学习参考https://blog.csdn.net/qq_32400847/article/details/51469917#include#include#include#include#include#includeusing namespace std;st... 阅读全文
posted @ 2018-08-30 23:33 MCQ 阅读(139) 评论(0) 推荐(0)
摘要:#includeusing namespace std;#define inf 0x3f3f3f3f#define ll long longconst int maxn=200005;const double eps=1e-8;const double PI = ac... 阅读全文
posted @ 2018-08-26 15:11 MCQ 阅读(112) 评论(0) 推荐(0)
摘要:6-12 二叉搜索树的操作集(30 分)本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType ... 阅读全文
posted @ 2018-08-24 21:08 MCQ 阅读(338) 评论(0) 推荐(0)
摘要:6-11 先序输出叶结点(15 分)本题要求按照先序遍历的顺序输出给定二叉树的叶结点。函数接口定义:void PreorderPrintLeaves( BinTree BT );其中BinTree结构定义如下:typedef struct TNode *Positio... 阅读全文
posted @ 2018-08-24 11:46 MCQ 阅读(711) 评论(0) 推荐(0)
摘要:#includeusing namespace std;typedef char ElementType;typedef struct TNode *Position;typedef Position BinTree;struct TNode{ ElementT... 阅读全文
posted @ 2018-08-24 10:54 MCQ 阅读(186) 评论(0) 推荐(0)
摘要:6-7 在一个数组中实现两个堆栈(20 分)本题要求在一个数组中实现两个堆栈。函数接口定义:Stack CreateStack( int MaxSize );bool Push( Stack S, ElementType X, int Tag );ElementTyp... 阅读全文
posted @ 2018-07-29 19:56 MCQ 阅读(1207) 评论(0) 推荐(0)
摘要:6-5 链式表操作集(20 分)本题要求实现链式表的操作集。函数接口定义:Position Find( List L, ElementType X );List Insert( List L, ElementType X, Position P );List Dele... 阅读全文
posted @ 2018-07-28 22:00 MCQ 阅读(675) 评论(0) 推荐(0)
摘要:6-2 顺序表操作集(20 分)本题要求实现顺序表的操作集。函数接口定义:List MakeEmpty(); Position Find( List L, ElementType X );bool Insert( List L, ElementType X, Pos... 阅读全文
posted @ 2018-07-27 10:47 MCQ 阅读(393) 评论(0) 推荐(0)
摘要:void PreorderTraversal(BinTree BT){ if(BT==NULL) return; printf(" %c",BT->Data); PreorderTraversal(BT->Left); PreorderTraversal... 阅读全文
posted @ 2018-07-21 10:47 MCQ 阅读(193) 评论(0) 推荐(0)
摘要:List Reverse( List L ){ List p,q; p=L; L=NULL; while(p){ q=p; p=p->Next; q->Next=L; L=q; } return L;} 阅读全文
posted @ 2018-07-21 09:37 MCQ 阅读(90) 评论(0) 推荐(0)
摘要:#includeusing namespace std;#define inf 0x3f3f3f3f#define ll long long#define fo freopen("in.txt","r",stdin)#define fc fclose(stdin)#d... 阅读全文
posted @ 2018-07-19 17:28 MCQ 阅读(273) 评论(0) 推荐(0)