I think Nitish is right. The output shoud be as mentioned by Nitish. And the code for that
#include<stdio.h> int n; void f(int *,int,int,int); int main() { scanf("%d",&n); int arr[n]; f(arr,0,0,0); getchar(); getchar(); return 0; } void f(int arr[], int open, int close, int index) { if (close==n) { for (int i=0;i<n*2;i++) printf("%d",arr[i]); printf("\n"); return ; } else { if (open<n) { arr[index] = 1; f(arr,open+1,close,index+1); } if (close<open) { arr[index]=0; f(arr,open,close+1,index+1); } } } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/caAn1qhOpTUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.