Generating Permutations
A permutation can be obtained by selecting an element in the given set and recursively permuting the remaining elements.


permute(i) if i == N output A[N] else for j = i to N do swap(A[i], A[j]) permute(i+1) swap(A[i], A[j])
posted on 2011-09-21 15:22 Zero Lee 閱讀(265) 評論(0) 編輯 收藏 引用 所屬分類: Data structure and algorithms