- 博客(4)
- 收藏
- 关注
原创 重构二叉树(根据前序和中序)
题目来源:http://cie.xtu.edu.cn/exam/index.php/problem/exam_read/id/1046/exam_id/33题目大意:给出一个二叉树的前序和中序遍历,重构二叉树,然后查找指定结点的孩子结点,参考了网上的算法。// 重构二叉树.cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#include "iostream
2011-12-06 17:05:16
414
原创 二叉排序树的创建和查找
//head2.h#include #include using namespace std;templateclass BinarySortTree{private: typedef struct BinaryNode { type data; BinaryNode* left; BinaryNode* right; BinaryNode(type dt,Bin
2011-12-06 16:55:33
497
原创 Kruskal+并查集:John的农场
研究了半天,利用Kruskal结合并查集搞定了最小生成树,代码感觉还是很清晰的。//John的农场(最小生成树).cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#include #include #include using namespace std;struct Node{ int v1,v2; int weight;
2011-12-03 18:50:29
1619
原创 DFS做小希的迷宫(图论)
第一次学习写DFS,什么都不会,只能写出这些东西,大牛见了还请批评指正!// 小希的迷宫.cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#include #include using namespace std;struct Edge//用结构体存储边信息,flag表示该边是否被选取。{ int v1,v2; int flag;
2011-12-02 16:59:33
379
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅