随笔分类 - 算法
摘要:一、简介“D*算法”的名称源自 Dynamic A Star,最初由Anthony Stentz于“Optimal and Efficient Path Planning for Partially-Known Environments”中介绍。它是一种启发式的路径搜索算法,适合面对周围环境未知或者
阅读全文
摘要:所有的套路都只是提供一种思想,列出来的是典型的格式,切不可每道题都生搬硬套 提高语言表达能力:不管这个想法是否正确,把自己的想法用代码快速表示出来的能力 总结出每一种套路的特性,每种套路分别需要知道哪些信息、条件才能使用这种套路,从题目中抽取这些信息 不要一开始就想着用什么套路可以解题,要从问题出发
阅读全文
摘要:原文: https://www.cnblogs.com/dreamyu/p/13210713.html 回溯与DFS的区别: 1,区别不在于回溯,因为dfs也会回溯,而是dfs会将已经访问过的点标记为不可再次连接,不会再撤销,从而使得可搜索路径越来越少,而回溯会在访问初标记,回溯时撤销。使用邻接链表
阅读全文
摘要:问题: Serling公司购买长钢条,将其切割为短钢条出售。不同的切割方案,收益是不同的,怎么切割才能有最大的收益呢?假设,切割工序本身没有成本支出。 假定出售一段长度为i英寸的钢条的价格为p i (i=1,2,…)。钢条的长度为n英寸。如下给出一个价格表P。 给定一段长度为n英寸的钢条和一个价格表
阅读全文
摘要:1 #include <iostream> 2 #include <map> 3 #include <fstream> 4 #include <set> 5 #include <vector> 6 #include <algorithm> 7 #include <stack> 8 9 using n
阅读全文
摘要:1 #include <iostream> 2 #include <map> 3 #include <fstream> 4 #include <set> 5 #include <vector> 6 #include <algorithm> 7 8 using namespace std; 9 10
阅读全文
摘要:1 #include <iostream> 2 3 using namespace std; 4 5 template <typename K, typename V> 6 class BST 7 { 8 private: 9 struct node // 类内定义类、结构体 10 { 11 K k
阅读全文
摘要:1 #include <iostream> 2 3 using namespace std; 4 5 #define ARR_SIZE 20 6 7 void CreateRandArr(int a[]); 8 9 template <typename T> 10 class MaxPQ 11 {
阅读全文
摘要:1 #include <iostream> 2 #include <cstdlib> 3 4 #define ARR_SIZE 10 5 6 using namespace std; 7 8 9 void quicksort(int a[], int lo, int hi); 10 int part
阅读全文
摘要:1 #include <iostream> 2 #include <cstdlib> 3 4 #define ARR_SIZE 10 5 6 using namespace std; 7 8 void shellshort(int a[]); 9 void CreateRandArr(int a[]
阅读全文
摘要:1 #include <iostream> 2 #include <cstdlib> 3 4 #define ARR_SIZE 20 5 #define MIN(x, y) (x)>(y)?(y):(x) 6 using namespace std; 7 8 int kk= 0; 9 10 void
阅读全文
摘要:1 #include <iostream> 2 #include <cstdlib> 3 4 #define ARR_SIZE 10 5 6 using namespace std; 7 8 /* 想象一下打牌时发完牌整理的时候,不同的是打牌我们一眼就能看出来这张牌应该插在哪个位置,而插入排序要逐一
阅读全文
摘要:1 /* 选择排序 */ 2 3 #include <iostream> 4 #include <cstdlib> 5 6 #define ARR_SIZE 10 7 8 using namespace std; 9 10 void chosesort(int a[]); 11 void Creat
阅读全文
摘要:二分查找:查找已排序数组中的某个值 算法过程: 将欲查找元素与数组中间值(a[mid])对比,每次查找的数组大小减半。如果欲查找的值存在于数组中,则必定在某次循环中通过a[mid]返回 查找的次数最多可能为:log2(N)次(N为数组大小),因为查找次数最多时最后一次查找为2个数中的一个,每次查找都
阅读全文