Solving Permutations Problems: Finding Algorithms & Optimizing Efficiency

Click For Summary
SUMMARY

This discussion focuses on solving two permutation problems involving algorithms with specific time complexities. The first problem requires finding an algorithm that computes the Kth composition of a given permutation in O(N log K) time, while the second problem involves determining the number of cycles in a permutation in O(N) time. A proposed strategy for the first problem involves using repeated applications of the permutation to efficiently compute the result, leveraging the concept of exponentiation by squaring.

PREREQUISITES
  • Understanding of permutations and their compositions
  • Familiarity with algorithmic time complexity analysis
  • Knowledge of cycle decomposition in permutations
  • Experience with algorithm design techniques, particularly exponentiation by squaring
NEXT STEPS
  • Research "Exponentiation by Squaring" for efficient algorithm design
  • Study "Cycle Decomposition in Permutations" to understand counting cycles
  • Explore "O(N log K) Algorithms" for performance optimization techniques
  • Learn about "Graph Theory Applications in Permutations" for deeper insights
USEFUL FOR

Mathematicians, computer scientists, algorithm developers, and students tackling advanced permutation problems and seeking to optimize algorithm efficiency.

alejandrito
Messages
7
Reaction score
0
I have two problems on permutations which I can´t solve now because 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.
 
Technology news on Phys.org
This sounds like a homework problem. Can you show use any type of thought process before we start giving you hints.
 
Here's an example of a Permutation P on n=4 elements:
Code:
|x1 x2 x3 x4|
| 4  3  2  1|
This Permutation P sends element x1 to #4 spot, x2 to #3 ...etc, producing:
Code:
|x4 x3 x2 x1|

What happens if you apply permutation P twice? Then:
Code:
|x1 x2 x3 x4|
| 4  3  2  1|
|x4 x3 x2 x1|
| 4  3  2  1|
|x1 x2 x3 x4|
This would be the second composition of P. Notice that the resulting permutation of the 2nd Composition of P is the original arrangement of the n elements, so this is a cycle. Of course this isn't the case for every possible P. Suppose that a permutation Q moves each element xi one place to the right (wrapping around), then, it will go back to the original arrangement only at the nth (in this case the 4th) composition of Q.
In your first question you're asked to find the kth composition of a permutation P. Obviously you can do this in O(Nk) time (n elements and k applications of permutation P). You need to squeeze this into O(N log k). Here's a strategy:
Let A1 be a permutation equal to two applications of permutation P. Then let A2 be a permutation equal to two applications of permutation A1 (4 of P). Let A3 be two applications of A2 (8 of P).. etc. Then, if k = 8:
the permutation A3 gives you the kth composition of P. If k = 9, then A3 followed by P gives you the kth composition of P. If k = 10, then A3 followed by A1 gives you the kth composition of p ..etc. If k > 16 then you need to compute A4, and so on. This takes at most 2*N*log k = O(N log k).
Now all you need is to do is turn this into an algorithm which should be easy enough.
 
Last edited:

Similar threads

Replies
9
Views
2K
  • · Replies 11 ·
Replies
11
Views
5K
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
8
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
3K
Replies
4
Views
1K