Interviewer ask me to solve some permutation related problems. 1) Algorithm to get Index of a permutation when all permutations arranged in lexicographical order and its complexity
Sigiloso
The permutations in lexigraphic order look like this 012345 ... ( 5!-1 more permutations that start with 0 ) 102345 ... ( 5!-1 more permutations that start with 1 ) 201345 ... ( 5!-1 more permutations that start with 2 ) So if the permutation starts with a 2 its position is 2 * 5! + (offset within the list that starts with a 2) I think this is a start of an efficient recursive method for determining the position, but in the recursion you have to translate the remaining digits properly...