Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikkukreja/624311cf756395f4f065 to your computer and use it in GitHub Desktop.
Save kartikkukreja/624311cf756395f4f065 to your computer and use it in GitHub Desktop.
Solution permutation with pre-order traversal of balanced BST
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