
数据结构
怎呼虹
你只负责精彩,命运自有安排。
展开
-
POJ 2255 Tree Revovery 二叉树遍历序列推导
二叉树本就是一种递归数据结构,题是要根据给出的二叉树的先序遍历序列和中序遍历序列推出后序遍历序列。PS:构建二叉树的过程本就是遍历的过程。两种递归代码。传送门:POJ-2255-Tree Revovery#include <stdio.h> #include <string.h> char F[100],M[100]; // f:先序序列index // b:中序序列begin // e:中序序列e原创 2016-08-10 23:00:37 · 469 阅读 · 0 评论 -
HDU 1053 Entropy 模拟哈夫曼树
传送门:HDU 1053 Entropy分析: 就是简单的模拟题。 模拟哈夫曼树的构建过程。 技巧:利用tmp中间数组做中转模拟构建过程。 详见代码:#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int num[27]; int fun() { int n = 0,i,j原创 2016-12-28 00:14:05 · 477 阅读 · 0 评论 -
POJ 2503 Babelfish STL-map容器
传送门:POJ 2503 Babelfish分析: 利用map容器的键值属性对,通过键高效查找值。代码如下:#include <iostream> #include <cstdio> #include <map> #include <string> using namespace std; int main() { int i; char str[25],a[12],b[12];原创 2017-01-19 11:23:37 · 457 阅读 · 0 评论 -
POJ 3253 Fence Repair 哈夫曼树
传送门:POJ 3253 Fence Repair分析: 常规模拟代码麻烦,采用STL中的multiset数据结构进行哈夫曼树的模拟构建。代码如下:#include <stdio.h> #include <algorithm> #include <set> using namespace std; int wood[20001],n; typedef long long LL; int main(原创 2017-02-25 18:49:55 · 405 阅读 · 0 评论