
Algorithm
wlz_123
这个作者很懒,什么都没留下…
展开
-
汉诺塔
#includeusing namespace std;void move(int n ,char x,char y,char z){ if(1==n) { cout" } else { move(n-1,x,z,y); cout" move(n-1,y,x,z);原创 2017-10-08 11:23:29 · 170 阅读 · 0 评论 -
最长递增子序列
#include#include#includeusing namespace std;vectorget(vector&abc){ int len=abc.size(); vector dp(len); vector res(len); dp[0]=abc[0]; res[0]=1; int right=0原创 2017-10-30 11:45:01 · 160 阅读 · 0 评论 -
杂项1
#include#includeusing namespace std;int s(int arr[],int i,int j);int f(int arr[],int i,int j){ if(i==j) return arr[i]; return max(arr[i]+s(arr,i+1,j),arr[j]+s(arr,i,j-1));}int s(原创 2017-12-08 18:25:13 · 135 阅读 · 0 评论 -
杂项二
#includeusing namespace std;int MaxLen(int arr[],int k ,int length){ int left=0; int right=0; int sum=arr[0]; int res=0; while(right if(sum==k){ if(res原创 2017-12-09 10:38:17 · 140 阅读 · 0 评论 -
KMP NEXT数组的求解
#include#includevoid Next(const char ss[],int next[]){ int q; int k=-1; int m = strlen(ss); next[0] = -1; next[1]=0; for (q = 2; q { while(k > -1 &&原创 2017-12-14 10:18:17 · 424 阅读 · 0 评论 -
树的遍历
前言在前两篇文章二叉树和二叉搜索树中已经涉及到了二叉树的三种遍历。递归写法,只要理解思想,几行代码。可是非递归写法却很不容易。这里特地总结下,透彻解析它们的非递归写法。其中,中序遍历的非递归写法最简单,后序遍历最难。我们的讨论基础是这样的: [cpp] view plain copy//Binary Tree Node转载 2017-12-14 10:41:04 · 228 阅读 · 0 评论 -
堆排序
#include#includeusing namespace std;//////构造大顶堆,时间复杂度O(logn)void make_maxheap(int a[],int start,int end1){ int f=start; int s=2*f+1; while(s if(( (s+1) s++原创 2017-11-17 09:12:35 · 148 阅读 · 0 评论