├── 考试题库.PNG
├── 课件
├── 6 回溯法.ppt
├── 1 算法概述.ppt
├── 2 暴力搜索.ppt
├── 4 动态规划.ppt
├── 5 贪心算法.ppt
└── 3 递归与分治策略.ppt
├── 1.暴力
├── 价牌问题.txt
├── 勾股定理问题.txt
├── 字典序问题.txt
├── 最多约数问题.txt
├── 最大公约数.txt
├── 最大间隙问题.txt
├── 统计数字问题.txt
├── 背包问题.txt
├── 金币阵列问题.txt
├── 将两个正整数的最大公约数表示成两个数的线性组合.txt
├── fibonacci数列.txt
└── 多少个1组成的整数可以被2011整除.txt
├── 2.递归与分治
├── 半数集.txt
├── L型骨牌.txt
├── 众数问题.txt
├── 半数单集.txt
├── 合并排序.txt
├── 大数运算.txt
├── 大数阶乘.txt
├── 循环赛日程表.txt
├── 排列的字典序问题.txt
├── 整数划分问题.txt
├── 整数因子分解问题.txt
├── 标准二维表问题.txt
├── 集合划分问题.txt
├── 有重复元素的排列问题.txt
├── 马的Hamilton周游路线.txt
├── 排列问题.txt
└── 快速排序.txt
├── 4.贪心算法
├── 删数问题.txt
├── 会场安排问题.txt
├── 最优分解问题.txt
├── 最优合并问题.txt
├── 汽车加油问题.txt
├── 最优服务次序问题.txt
└── 多处最优服务次序问题.txt
├── 5.回溯
├── n皇后问题.txt
├── 子集和问题.txt
├── 工作分配问题.txt
├── 拉丁矩阵问题.txt
├── 数字排列问题.txt
├── 数独问题.txt
├── 李白打酒.txt
├── 正方形问题.txt
├── 连续邮资问题.txt
├── 迷宫问题.txt
├── 0-1背包问题.txt
├── 39级台阶问题.txt
├── 图的m着色问题.txt
├── 批处理作业调度.txt
├── 符号三角形问题.txt
└── 最小重量机器设计问题.txt
├── 3.动态规划
├── 电路布线问题.txt
├── 石子合并问题.txt
├── 租用游艇问题.txt
├── 0-1背包问题.txt
├── 数字三角形问题.txt
├── 最大k乘积问题.txt
├── 最小m段和问题.txt
├── 流水作业调度问题.txt
├── 矩阵连乘问题-递归.txt
├── 最大子段和(三种方法).txt
├── 独立任务最优调度问题.txt
├── 矩阵连乘问题-动态规划.txt
├── 矩阵连乘问题-备忘录.txt
├── 最长公共子序列问题(三种方法).txt
└── 矩阵乘法.txt
└── README.md
/考试题库.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/考试题库.PNG
--------------------------------------------------------------------------------
/课件/6 回溯法.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/课件/6 回溯法.ppt
--------------------------------------------------------------------------------
/1.暴力/价牌问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/价牌问题.txt
--------------------------------------------------------------------------------
/1.暴力/勾股定理问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/勾股定理问题.txt
--------------------------------------------------------------------------------
/1.暴力/字典序问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/字典序问题.txt
--------------------------------------------------------------------------------
/1.暴力/最多约数问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/最多约数问题.txt
--------------------------------------------------------------------------------
/1.暴力/最大公约数.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/最大公约数.txt
--------------------------------------------------------------------------------
/1.暴力/最大间隙问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/最大间隙问题.txt
--------------------------------------------------------------------------------
/1.暴力/统计数字问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/统计数字问题.txt
--------------------------------------------------------------------------------
/1.暴力/背包问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/背包问题.txt
--------------------------------------------------------------------------------
/1.暴力/金币阵列问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/金币阵列问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/半数集.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/半数集.txt
--------------------------------------------------------------------------------
/4.贪心算法/删数问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/删数问题.txt
--------------------------------------------------------------------------------
/5.回溯/n皇后问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/n皇后问题.txt
--------------------------------------------------------------------------------
/5.回溯/子集和问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/子集和问题.txt
--------------------------------------------------------------------------------
/5.回溯/工作分配问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/工作分配问题.txt
--------------------------------------------------------------------------------
/5.回溯/拉丁矩阵问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/拉丁矩阵问题.txt
--------------------------------------------------------------------------------
/5.回溯/数字排列问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/数字排列问题.txt
--------------------------------------------------------------------------------
/5.回溯/数独问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/数独问题.txt
--------------------------------------------------------------------------------
/5.回溯/李白打酒.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/李白打酒.txt
--------------------------------------------------------------------------------
/5.回溯/正方形问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/正方形问题.txt
--------------------------------------------------------------------------------
/5.回溯/连续邮资问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/连续邮资问题.txt
--------------------------------------------------------------------------------
/5.回溯/迷宫问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/迷宫问题.txt
--------------------------------------------------------------------------------
/课件/1 算法概述.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/课件/1 算法概述.ppt
--------------------------------------------------------------------------------
/课件/2 暴力搜索.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/课件/2 暴力搜索.ppt
--------------------------------------------------------------------------------
/课件/4 动态规划.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/课件/4 动态规划.ppt
--------------------------------------------------------------------------------
/课件/5 贪心算法.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/课件/5 贪心算法.ppt
--------------------------------------------------------------------------------
/2.递归与分治/L型骨牌.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/L型骨牌.txt
--------------------------------------------------------------------------------
/2.递归与分治/众数问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/众数问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/半数单集.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/半数单集.txt
--------------------------------------------------------------------------------
/2.递归与分治/合并排序.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/合并排序.txt
--------------------------------------------------------------------------------
/2.递归与分治/大数运算.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/大数运算.txt
--------------------------------------------------------------------------------
/2.递归与分治/大数阶乘.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/大数阶乘.txt
--------------------------------------------------------------------------------
/3.动态规划/电路布线问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/电路布线问题.txt
--------------------------------------------------------------------------------
/3.动态规划/石子合并问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/石子合并问题.txt
--------------------------------------------------------------------------------
/3.动态规划/租用游艇问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/租用游艇问题.txt
--------------------------------------------------------------------------------
/4.贪心算法/会场安排问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/会场安排问题.txt
--------------------------------------------------------------------------------
/4.贪心算法/最优分解问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/最优分解问题.txt
--------------------------------------------------------------------------------
/4.贪心算法/最优合并问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/最优合并问题.txt
--------------------------------------------------------------------------------
/4.贪心算法/汽车加油问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/汽车加油问题.txt
--------------------------------------------------------------------------------
/5.回溯/0-1背包问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/0-1背包问题.txt
--------------------------------------------------------------------------------
/5.回溯/39级台阶问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/39级台阶问题.txt
--------------------------------------------------------------------------------
/5.回溯/图的m着色问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/图的m着色问题.txt
--------------------------------------------------------------------------------
/5.回溯/批处理作业调度.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/批处理作业调度.txt
--------------------------------------------------------------------------------
/5.回溯/符号三角形问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/符号三角形问题.txt
--------------------------------------------------------------------------------
/课件/3 递归与分治策略.ppt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/课件/3 递归与分治策略.ppt
--------------------------------------------------------------------------------
/2.递归与分治/循环赛日程表.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/循环赛日程表.txt
--------------------------------------------------------------------------------
/2.递归与分治/排列的字典序问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/排列的字典序问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/整数划分问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/整数划分问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/整数因子分解问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/整数因子分解问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/标准二维表问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/标准二维表问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/集合划分问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/集合划分问题.txt
--------------------------------------------------------------------------------
/3.动态规划/0-1背包问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/0-1背包问题.txt
--------------------------------------------------------------------------------
/3.动态规划/数字三角形问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/数字三角形问题.txt
--------------------------------------------------------------------------------
/3.动态规划/最大k乘积问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/最大k乘积问题.txt
--------------------------------------------------------------------------------
/3.动态规划/最小m段和问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/最小m段和问题.txt
--------------------------------------------------------------------------------
/3.动态规划/流水作业调度问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/流水作业调度问题.txt
--------------------------------------------------------------------------------
/3.动态规划/矩阵连乘问题-递归.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/矩阵连乘问题-递归.txt
--------------------------------------------------------------------------------
/4.贪心算法/最优服务次序问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/最优服务次序问题.txt
--------------------------------------------------------------------------------
/5.回溯/最小重量机器设计问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/5.回溯/最小重量机器设计问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/有重复元素的排列问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/有重复元素的排列问题.txt
--------------------------------------------------------------------------------
/3.动态规划/最大子段和(三种方法).txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/最大子段和(三种方法).txt
--------------------------------------------------------------------------------
/3.动态规划/独立任务最优调度问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/独立任务最优调度问题.txt
--------------------------------------------------------------------------------
/3.动态规划/矩阵连乘问题-动态规划.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/矩阵连乘问题-动态规划.txt
--------------------------------------------------------------------------------
/3.动态规划/矩阵连乘问题-备忘录.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/矩阵连乘问题-备忘录.txt
--------------------------------------------------------------------------------
/4.贪心算法/多处最优服务次序问题.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/4.贪心算法/多处最优服务次序问题.txt
--------------------------------------------------------------------------------
/2.递归与分治/马的Hamilton周游路线.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/2.递归与分治/马的Hamilton周游路线.txt
--------------------------------------------------------------------------------
/3.动态规划/最长公共子序列问题(三种方法).txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/3.动态规划/最长公共子序列问题(三种方法).txt
--------------------------------------------------------------------------------
/1.暴力/将两个正整数的最大公约数表示成两个数的线性组合.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jingong/Algorithm/HEAD/1.暴力/将两个正整数的最大公约数表示成两个数的线性组合.txt
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Algorithm
2 | 暴力、递归与分治、动态规划、贪心算法、回溯经典习题
3 |
4 | 这是本人在学习<<算法分析与程序设计>>这门课时做的算法题目,所有的代码均已测试通过。
5 |
6 | 这些代码在本人CSDN博客也有提交,博客地址:http://blog.csdn.net/iamjingong
7 |
--------------------------------------------------------------------------------
/1.暴力/fibonacci数列.txt:
--------------------------------------------------------------------------------
1 | #include
2 | int f(int n)
3 | {
4 | if (n == 1 || n == 2)
5 | return 1;
6 | else
7 | return f(n-1)+f(n-2);
8 | }
9 |
10 | int main()
11 | {
12 | int num;
13 | num = f(20);
14 | printf("%d",num);
15 | return 0;
16 | }
--------------------------------------------------------------------------------
/1.暴力/多少个1组成的整数可以被2011整除.txt:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int n = 1;
5 | int count = 0;
6 | n = n % 2011;
7 | while(1){
8 | count ++;
9 | if(n % 2011 == 0)
10 | break;
11 | else
12 | n = (n % 2011) * 10 + 1;
13 | }
14 | printf("%d",count);
15 | return 0;
16 | }
--------------------------------------------------------------------------------
/2.递归与分治/排列问题.txt:
--------------------------------------------------------------------------------
1 | #include
2 | #define n 3
3 | void perm(int a[],int begin,int end)
4 | {
5 | int t;
6 | if(begin == end)
7 | {
8 | for(int i = 0;i < n;i ++)
9 | printf("%d ",a[i]);
10 | putchar('\n');
11 | }
12 | else{
13 | for(int i = begin;i < n;i ++){
14 | t = a[begin];a[begin] = a[i];a[i] = t;
15 | perm(a,begin + 1,end);
16 | t = a[begin];a[begin] = a[i];a[i] = t;
17 | }
18 | }
19 | }
20 | int main()
21 | {
22 | int a[n] = {1,2,3};
23 | perm(a,0,2);
24 | return 0;
25 | }
--------------------------------------------------------------------------------
/3.动态规划/矩阵乘法.txt:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | int i,j,k;
6 | int a[2][3] = {{1,2,3},{2,1,3}};
7 | int b[3][2] = {{1,2},{2,1},{1,3}};
8 | int c[2][2];
9 | int sum;
10 | for(i = 0;i < 2;i ++){
11 | for(j = 0;j < 2;j ++){
12 | sum = 0;
13 | for(k = 0;k < 3;k ++){
14 | sum = sum + a[i][k] * b[k][j];
15 | }
16 | c[i][j] = sum;
17 | }
18 | }
19 | for(i = 0;i < 2;i ++){
20 | for(j = 0;j < 2;j ++){
21 | printf("%3d",c[i][j]);
22 | }
23 | printf("\n");
24 | }
25 | return 0;
26 | }
--------------------------------------------------------------------------------
/2.递归与分治/快速排序.txt:
--------------------------------------------------------------------------------
1 | #include
2 | #define n 9
3 | int partition(int a[],int left,int right)
4 | {
5 | int num = a[left];
6 | int i,j;
7 | int temp;
8 | i = left + 1;
9 | j = right;
10 | while(i < j){
11 | while(a[i] <= num && i <= right)
12 | i ++;
13 | while(a[j] > num)
14 | j --;
15 | if(i < j){
16 | temp = a[i];
17 | a[i] = a[j];
18 | a[j] = temp;
19 | }
20 | }
21 | a[left] = a[j];
22 | a[j] = num;
23 | return j;
24 | }
25 | void quicksort(int a[],int left,int right)
26 | {
27 | int pos;
28 | if(left < right)
29 | {
30 | pos = partition(a,left,right);
31 | quicksort(a,left,pos - 1);
32 | quicksort(a,pos + 1,right);
33 | }
34 | }
35 | int main(){
36 | int i;
37 | int a[n] = {4,5,2,6,8,1,3,9,7};
38 | quicksort(a,0,n - 1);
39 | for(i = 0;i < n;i ++){
40 | printf("%d ",a[i]);
41 | }
42 | putchar('\n');
43 | return 0;
44 | }
--------------------------------------------------------------------------------