JS Permutation Algo

NameJS Permutation Algo
AuthorPi Ke
TypeSource Code
Size918.00 B
Date2011-09-24 13:04:23
Downloads15
TagJavaScript,Permutation,Algorithm,Impleme

  ::Description

In secondary school, we have learned permutation. Basically, for n numbers, the number of permutations for these n numbers can be calculated to n! which is called \'n factorial\'. But to display all the permutations on the screen, we need to use a recursive function. The problem is how to write this function. 
Next I write a program to display the permutations for n numbers with JavaScript. First, we need to understand that from these n numbers, we can first take any one number from it, and the (n-1) numbers remaining has the similar property as the n numbers, we need to find the permutations for the (n-1) numbers, and from these (n-1) numbers, we take any one of them and there are (n-2) numbers which we need to find the permutations of them. So the whole process will stop when there is only one number left, we will can display the permutations. It is a recursive process. 


 
   (Views : 6516 Downloads : 15 )

Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr    Delicious

  ::User say

No comment for this article.

  ::Comment

Comment is disabled on this page