摘要: 分治法:是将待求解的原问题划分成若干个相互独立的子问题,通过求解子问题并将子问题的解合并,自底向上逐步求出原问题的解。 动态规划法:是将待求解问题分解成若干个相互重叠的子问题,每个子问题对应决策过程的一个阶段,一般来说,子问题的重叠关系表现在对给定问题求解的递推关系(也就是动态规划函数)中,将子问题 阅读全文
posted @ 2019-06-17 09:30 夜游星 阅读(468) 评论(0) 推荐(0) 编辑
摘要: 1. 分治法能解决的问题一般具有什么特征2. 解空间树的动态搜索过程3. 递归优点?那为什么有的问题还要用非递归 动态规划法与分治法的异同、动态规划法与贪心法的异同、分支限界与回溯 分析性能特点。例,填表:动态规划法画图:贪心法求TSP、图着色,回溯法、分支限界法 5、a.为一个分治算法编写伪代码, 阅读全文
posted @ 2019-06-17 09:29 夜游星 阅读(442) 评论(0) 推荐(0) 编辑
摘要: 1.回溯法编程求解0-1背包问题 #include<stdio.h> #include<iostream> using namespace std; int c,n; int cv=0,cw=0,mv=0,mw=0; int weight[20],value[20]; int x[20],bestv 阅读全文
posted @ 2019-06-17 08:53 夜游星 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 1.单源最短路径问题 #include<stdio.h> #include<iostream> #include<cmath> using namespace std; #define M 1000 int Cost[20][20]; int n; int Distance[20]; bool s[ 阅读全文
posted @ 2019-06-17 08:50 夜游星 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 利用动态规划算法编程求解TSP问题 #include<stdio.h> #include<iostream> #include<cmath> using namespace std; #define INF 9000 int mp[20][20]; int n; int dp[20][1<<20]; 阅读全文
posted @ 2019-06-17 08:48 夜游星 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 1.循环赛日程表安排问题 #include<stdio.h> #include <stdlib.h> #include <cmath> #include <iostream> using namespace std; void GameTable(int k, int a[50][50]) { in 阅读全文
posted @ 2019-06-17 08:45 夜游星 阅读(358) 评论(0) 推荐(0) 编辑