Is there a way to find the nth string of characters from an alphabet, without having to store "all" of the combinations?
Example:
Alphabet $A = \{a,b,c\}, n=12$.
All possible combinations in lexicographic order are $C = \{a, ab, abc, ac, acb, b, ba, bac, bc, bca, c, ca, cab, cb, cba\}$.
You can see that there's no repetition of characters in any string and the empty string is not a member of $A$.
So, the nth string is: $ca$.
Clearly, to find this I'm iterating over the set $C$.
The problem is that I have to generate all these strings, wich takes a really long time, and then search for the nth one. If the alphabet is large $(1 \leq A \leq 26 )$ the set $C$ grows too fast (not sure how much) and is impossible to store.
My questions is if exists a way to find these nth one, without generating all the strings.
Also, I'm not sure if this question goes in this StackExchange site.