permutation using recursion

Download Permutation Using Recursion

If you can't read please download the document

Upload: goktech1991

Post on 01-Oct-2015

2 views

Category:

Documents


0 download

DESCRIPTION

Permutation Using Recursion - A different approach

TRANSCRIPT

int len=4;void Perm(int i){if(i>len)return;else{generate_Perm(i++);Perm(i);}}int main(void) {// your code goes hereperm(0);return 0;}void perm(int i){if(i>len)return;else{perm(i++);}}void generate_Perm(int i){printf("%d",i);}char static in[]={'a','b','c','d'};int staic ref_arr[]={0,1,2,3};static int level=3,curr_level=1,length=4;perm(0);#include static char in[]={'a','b','c','d'};static int ref_arr[]={0,1,2,3};static int level=1,curr_level=1,length=4;int main(void) {// your code goes herevoid perm(int);perm(0);return 0;}#include static char in[]={'a','b','c','d'};static int ref_arr[]={0,0,0,0};static int level=4,curr_level=1,length=4;int main(void) {// your code goes herevoid perm(int);perm(0);return 0;}void perm(int i){ int j,k; if(i==length) { --curr_level; return; } if(curr_level==level) { while(i