- #1
alejandrito
- 7
- 0
I have two problems on permutations which I can´t solve now becuase my knowledge about permutations and the necessary tricks is very poor.
1st:
Find an algorithm that for given natural N (N<=1000), K and given permutation of N elements will find the Kth composition of this permutation in time less or equal to O(N log K).
2nd:
Find an algorithm that fot given natural N (N<=1000) and given permutation of N elements will determine the number of all cycles that the permutation is composed from in time less or equal to O(n).
Can anybody give me some hint related with any of this two problems, I´m mainly confused as to the satisfaction the maximal possible effecienty.
1st:
Find an algorithm that for given natural N (N<=1000), K and given permutation of N elements will find the Kth composition of this permutation in time less or equal to O(N log K).
2nd:
Find an algorithm that fot given natural N (N<=1000) and given permutation of N elements will determine the number of all cycles that the permutation is composed from in time less or equal to O(n).
Can anybody give me some hint related with any of this two problems, I´m mainly confused as to the satisfaction the maximal possible effecienty.