议题:快速排序实现之五(非递归实现,短序列优先处理,减少递归栈大小)分析:算法原理:此算法实现适用于系统栈空间不足够快速排序递归调用的需求,从而使用非递归实现快速排序算法;使用显示下推栈存储快速排序中的每一次划分结果
(将left和right都压入堆栈),并且首先处理划分序列较短的子序列(也就是在得...
分类:
其他好文 时间:
2014-06-03 08:23:29
阅读次数:
367
An iterative way of writing merge sort:
#include
using namespace std;
void merge(int A[], int l, int r, int e, int B[]) {
int i = l, j = r, k = l;
while (i<r && j A[j]) B[k++] =...
分类:
其他好文 时间:
2014-06-03 02:33:24
阅读次数:
215
An iterative way of writing quick sort:
#include
#include
#include
using namespace std;
void quickSort(int A[], int n) {
stack> stk;
stk.push(make_pair(0, n-1));
while (!stk.empty()) {
pair ...
分类:
其他好文 时间:
2014-06-03 00:16:43
阅读次数:
357
本文地址:http://www.cnblogs.com/archimedes/p/recursive-practice.html,转载请注明源地址。1、炮弹一样的球状物体,能够堆积成一个金字塔,在顶端有一个炮弹,它坐落在一个4个炮弹组成的层面上,而这4个炮弹又坐落在一个9个炮弹组成的层面上,以此类推...
分类:
编程语言 时间:
2014-05-26 13:12:52
阅读次数:
354
using recursive and bitwise methods to get
string combinations.
分类:
其他好文 时间:
2014-05-25 12:26:56
阅读次数:
187
Determine whether an integer is a palindrome.
Do this without extra space.if use recursive, like check the first dig and last
dig, then remove them, c...
分类:
其他好文 时间:
2014-05-23 02:45:15
阅读次数:
230
这道题最开始采用recursive的方法,结果犯了TLE(time limit
exceeded)的错误,事实证明recursive的时间代价还是太高,所以改用DP的方法,把曾经算出来的结果存起来,我用的是一个M*N的matrix来存储 1
public class Solution { 2 ...
分类:
其他好文 时间:
2014-05-14 10:57:31
阅读次数:
245
1. Write a procedure count-list to count the
number of elements in a list1 (defun count-list (numbers)2 (if (null numbers) 03
(+ 1 (co...
分类:
其他好文 时间:
2014-05-09 05:41:41
阅读次数:
307
代表四种检出深度: 1、Fully
recursive——全递归:检出完整的目录树,包含所有的文件或子目录。2、Immediate children,including
folders——直接子节点,包含文件夹:检出目录,包含其中的文件或子目录,但是不递归展开子目录。3、Only file chli...
分类:
其他好文 时间:
2014-05-08 20:08:29
阅读次数:
290
/** 01背包,recursive* 05.08/2014*/#include #include
#include #define MAXN 30000using namespace std;int N,W;int w[MAXN],v[MAXN];int
solve(int i, int tw)....
分类:
其他好文 时间:
2014-05-08 14:54:25
阅读次数:
271