
算法设计
春风不解风情T
这个作者很懒,什么都没留下…
展开
-
二叉树的递归创建以及遍历、求深度等功能
二叉树的常规功能 #include<stdio.h> #include<stdlib.h> typedef struct tree { char val; struct tree * leftChild; struct tree * rightChild; struct tree * parent; }Tree,*CTree; int flag=0; void Init(CTree &root){ root->val = ' '原创 2022-04-14 01:34:24 · 1054 阅读 · 0 评论 -
基本算法的实现
算法 贪心算法 特殊的01背包问题:各物品按重量递增排列时其价值恰好按递减排序 贪心算法可以求解特殊的01背包问题得出来最优解,但是若用贪心算法解决普通的背包问题的话,一般只能求出来近似解,求不出来最优解。 动态规划 动态规划解决背包问题 #include <iostream> #include <string.h> using namespace std; int main() { int w[4]={2,1,3,2}; int v[4]={12,10,20,15原创 2021-10-08 16:57:58 · 1470 阅读 · 0 评论