二叉树定义:
1.有且仅有一个特定的称之为根root的结点
2.当n>1时,除根结点之外的其余结点分为两个互不相交的子集。他们称为二叉树的左子树和右子树。
二叉树的一种建立方法:
若对有n个结点的完全二叉树进行顺序编号(1=1)的结点。
当i=1时,该结点为根,它无双亲结点;
当i>1时,该节点的双亲编号为[i/2];
若2i
当2i+1
利用上个性质,对任意二叉树,先按满二叉树...
分类:
其他好文 时间:
2015-06-09 10:04:17
阅读次数:
223
题目描述想兑换100元钱,有1,2,5,10四种钱,问总共有多少兑换方法递归解法#include
using namespace std; const int N = 100;
int dimes[] = {1, 2, 5, 10};
int arr[N+1] = {1}; int coinExchangeRecursion(int n, int m) //递归方式实现...
分类:
其他好文 时间:
2015-06-09 09:57:23
阅读次数:
534
【递归经典题目】汉诺塔算法 Java实现汉诺塔非递归算法
分类:
编程语言 时间:
2015-06-08 11:30:14
阅读次数:
97
CodeForces 490E Restoring Increasing Sequence(贪心)
CodeForces 490E
题目大意:给N个正整数,然而这些正整数中间有些数字是被‘?’遮挡住了,每个‘?’可以还原回一个数字,希望给定的这N个整数形成一个递增的序列。可以的话,给出这N个整数的序列,不行返回N0.
解题思路:每个整数都在满足条件的情况下尽量的小,写了一个非递归...
分类:
其他好文 时间:
2015-06-05 10:13:40
阅读次数:
110
啥也不说了 这是最基础的快速幂了 手打练习一下 非递归的有点点晕 都忘光了
直接上代码
非递归
{CSDN:CODE:R1W4K3P3l2T3S674K3Q1}
递归版本写出来是这个样子 两种都不对 原因未知!
//codevs3500 ??? ????????? ??
//copyright by ametake
#include
#include
#include
usi...
分类:
其他好文 时间:
2015-06-02 20:14:13
阅读次数:
86
Given a binary tree, return the inorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},1
\
2
/
3return [1,3,2].
题目要求对二叉树进行非递归的中序遍历,所谓前序遍历即,先访问左子树、再访问根节点、然...
分类:
其他好文 时间:
2015-06-01 22:47:56
阅读次数:
137
Given a binary tree, return the preorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},1
\
2
/
3return [1,2,3].Note: Recursive solution is trivial, could...
分类:
其他好文 时间:
2015-06-01 22:47:38
阅读次数:
128
Binary Tree Preorder Traversal:https://leetcode.com/problems/binary-tree-preorder-traversal/
Binary Tree Inorder Traversal :https://leetcode.com/problems/binary-tree-inorder-traversal/
Binary Tree Po...
分类:
其他好文 时间:
2015-06-01 22:45:30
阅读次数:
137
1、递归和非递归fac(n)=1*2*3*n(非递归)=n*fac(n-1)(递归)2、重载(java多态技术之一):同一个java文件中的不同方法3、覆写(java多态技术之一):子类覆写父类的方法4、封装:封装私有属性被公共访问5.实例变量和实例方法,静态变量和静态方法,最终变量和最终方法6.object中的toS..
分类:
编程语言 时间:
2015-05-31 01:39:40
阅读次数:
227
1.非递归版本#include #include using namespace std;void MergePass(int *arr,int *temp,int len,int step);void merge(int *temp,int *arr,int low,int mid,int hig...
分类:
编程语言 时间:
2015-05-30 21:07:17
阅读次数:
144