摘要: 题目链接:POJ 3278 Describe: Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 阅读全文
posted @ 2020-09-01 09:25 不敢说的梦 阅读(157) 评论(0) 推荐(0)
摘要: 题目链接:POJ 2251 Describe: You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may 阅读全文
posted @ 2020-08-23 21:13 不敢说的梦 阅读(122) 评论(0) 推荐(0)
摘要: 快速排序: 有点归并排序的思想,分而治之。主要分为主元选取,子集划分两个阶段。主元选取有点讲究,不同的主元会导致运算效率不同,并且排序数量的大小也会影响效率,如果排序数为100以下,有时插入排序要比快速排序效率更高,此时可以设定一个阈值来确定用哪个排序算法。 示例代码: 此处为了方便,将要排序的最右 阅读全文
posted @ 2020-08-21 13:43 不敢说的梦 阅读(162) 评论(0) 推荐(0)
摘要: 归并排序: 顾名思义,就是将要排序的一串数一分为二,递归的去排序左边和右边的数,最终合并到一起,以从小到大排序为例 参考代码: 1 // Merge sort 2 #include <iostream> 3 using namespace std; 4 void mergenum(int a[], 阅读全文
posted @ 2020-08-21 13:21 不敢说的梦 阅读(153) 评论(0) 推荐(0)
摘要: 注:所有排序以从小到大排序为例,且函数接口统一定义为:void sortname_sort(int a[], int n) 简单排序: 简单排序有三种:选择排序,冒泡排序,插入排序。其中选择排序非常简单,就是从要排序的数列里找到最小的放在最前面,以此类推,最终完成排序,代码省略。 冒泡排序: 思路是 阅读全文
posted @ 2020-08-21 11:32 不敢说的梦 阅读(201) 评论(0) 推荐(0)
摘要: 题目链接:POJ 1258 Describe: Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms i 阅读全文
posted @ 2020-08-19 11:25 不敢说的梦 阅读(256) 评论(0) 推荐(0)
摘要: 题目链接:POJ 2421 Describe: There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect 阅读全文
posted @ 2020-08-18 17:22 不敢说的梦 阅读(126) 评论(0) 推荐(0)
摘要: 题目链接:POJ 1094 Describe: An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the element 阅读全文
posted @ 2020-08-18 11:14 不敢说的梦 阅读(107) 评论(0) 推荐(0)
摘要: d题目链接: POJ 3253 Describe: Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N 阅读全文
posted @ 2020-08-14 19:09 不敢说的梦 阅读(121) 评论(0) 推荐(0)
摘要: 哈夫曼树: 定义: 给定N个权值作为N个叶子结点,构造一棵二叉树,若该树的带权路径长度达到最小,称这样的二叉树为最优二叉树,也称为哈夫曼树(Huffman Tree)。哈夫曼树是带权路径长度最短的树,权值较大的结点离根较近。(摘自:百度百科) 基本术语: 路径长度:从根节点到某节点通路上分支的数目, 阅读全文
posted @ 2020-08-14 13:56 不敢说的梦 阅读(490) 评论(0) 推荐(0)