Last active
August 29, 2015 14:08
-
-
Save kartikkukreja/624311cf756395f4f065 to your computer and use it in GitHub Desktop.
Solution permutation with pre-order traversal of balanced BST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void print_permutation(int lo, int hi) { | |
if (lo > hi) | |
return; | |
int mid = (lo + hi) / 2; | |
printf("%d ", mid); | |
print_permutation(lo, mid-1); | |
print_permutation(mid+1, hi); | |
} | |
void print_permutation(int N) { | |
print_permutation(1, N); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment