随笔 - 81  文章 - 0  评论 - 0  阅读 - 7151 
02 2020 档案
树算法专题(一)二叉树
摘要:一、二叉树的基本操作 1、二叉树存储结构 2、二叉树结点的查找、修改 3、二叉树结点的插入 4、二叉树的创建 二、二叉树的遍历 1、先序遍历 2、中序遍历 3、后序遍历 4、层次遍历 5、问题:知先中输后层 Sample Input 9 1 2 4 7 3 5 8 9 6 4 7 2 1 8 5 9 阅读全文
posted @ 2020-02-29 10:46 晨曦生辉耀匕尖 编辑
广度优先搜索(BFS)
摘要:一、问题: 输入: 6 70 1 1 1 0 0 10 0 1 0 0 0 00 0 0 0 1 0 00 0 0 1 1 1 01 1 1 0 1 0 01 1 1 1 0 0 0 输出: 4 代码: #include<iostream> #include<algorithm> #include< 阅读全文
posted @ 2020-02-28 17:31 晨曦生辉耀匕尖 编辑
深度优先搜索(DFS)
摘要:一、问题: 输入: 5 83 5 1 2 24 5 2 1 3 输出: 10 代码: #include<iostream> #include<algorithm> #include<vector> #include<cstdio> #include<cstdlib> using namespace 阅读全文
posted @ 2020-02-28 17:22 晨曦生辉耀匕尖 编辑
STL专题
摘要:一、algorithm 1、sort 问题1:给你n个整数,请按从大到小的顺序输出其中前m大的数。 Input:每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二行包含n个各不相同,且都处于区间[-500000,500000]的整数。Output:对每组测试数据按从大到小的 阅读全文
posted @ 2020-02-27 17:38 晨曦生辉耀匕尖 编辑
数论专题
摘要:一、素数判定 问题1:从键盘输入m,n,在屏幕上按每行10个的格式输出m~n之间的全部素数 输入 两个整数m n 输出 m~n间的素数,每行10个,每个数后用空格隔开。如果m和n为素数则包含。 样例输入 Copy 100 200 样例输出 Copy 101 103 107 109 113 127 1 阅读全文
posted @ 2020-02-25 15:50 晨曦生辉耀匕尖 编辑
动态规划专题
摘要:一、动态规划(背包问题) 问题1:Bone Collector(二维) Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect var 阅读全文
posted @ 2020-02-24 17:37 晨曦生辉耀匕尖 编辑
图算法专题(一)图的遍历
摘要:问题:Red and Black There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. 阅读全文
posted @ 2020-02-24 17:01 晨曦生辉耀匕尖 编辑
图算法专题(二)最短路径
摘要:一、Dijkstra算法 问题一: 输入: 6 8 00 1 10 3 40 4 41 3 22 5 13 2 23 4 34 5 3 输出: 0 1 5 3 4 6 代码: (1)邻接矩阵 #include<iostream> #include<algorithm> #include<queue> 阅读全文
posted @ 2020-02-24 16:54 晨曦生辉耀匕尖 编辑
树算法专题(三)并查集
摘要:问题:How Many Tables Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at 阅读全文
posted @ 2020-02-24 16:15 晨曦生辉耀匕尖 编辑
图算法专题(三)最小生成树
摘要:一、prim算法 问题:畅通工程 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input:测试输入包含若 阅读全文
posted @ 2020-02-24 15:39 晨曦生辉耀匕尖 编辑

点击右上角即可分享
微信分享提示