由买买提看人间百态

topics

全部话题 - 话题: quickperm
(共0页)
s**x
发帖数: 7506
1
来自主题: JobHunting版 - counting quickperm algorithm
this is used to do permutation without recursion.
哪位大侠能解释一下如何理解 这两句?
// IF i is odd then j = p[i] otherwise j = 0
// swap(a[j], a[i])
这个是算法的核心, 想了半天也不理解, 算法当然是对的。

http://www.freewebs.com/permute/quickperm.html
thanks!!!
// NOTICE: Copyright 2008, Phillip Paul Fuchs
#define N 12 // number of elements to permute. Let N > 2
void QuickPerm(void) {
unsigned int a[N], p[N];
register unsigned int i, j, tmp; // Upper Index i; Lower Index j
for(i = 0; i < N; i++) { // initialize... 阅读全帖
(共0页)