How to find the nth binary permutation?

  • Context: Undergrad 
  • Thread starter Thread starter Chadi B Ghaith
  • Start date Start date
  • Tags Tags
    Binary Permutation
Click For Summary
SUMMARY

The discussion focuses on finding the nth binary permutation of a 4-bit number with 2 bits set to 1, specifically the sequence starting from 0011. The total permutations for this configuration are calculated using the formula 4! / (2! * 2!) = 6, yielding the permutations 0011, 0101, 0110, 1001, 1010, and 1100. To find the nth permutation, such as the 5th permutation being 1010, one can utilize algorithms that determine the nth permutation in lexicographic order by analyzing the starting digits and their corresponding permutations.

PREREQUISITES
  • Understanding of binary representation and permutations
  • Familiarity with factorial calculations
  • Knowledge of lexicographic ordering
  • Basic algorithm design principles
NEXT STEPS
  • Study algorithms for generating permutations, focusing on lexicographic order
  • Learn about combinatorial mathematics, specifically factorial calculations
  • Explore programming implementations for finding nth permutations in various languages
  • Investigate optimization techniques for permutation generation
USEFUL FOR

Mathematicians, computer scientists, software developers, and anyone interested in combinatorial algorithms and binary data manipulation.

Chadi B Ghaith
Messages
35
Reaction score
4
I need to complete this.
Let's say I have 4 bits with 2 bits set as 1, 0011. The total number of permutations for this number is 0011, 0101, 0110, 1001, 1010, 1100, 6 cases. This can be computed using the calculation.

4! / ((2!)(4-2)!) = 6

Now I want to be able to find the nth sequence, for instance 1st number is 0011, second number is 0101. So if I say n=5, I want to be able to get the 5th permutation sequence 1010 from the initial 0011. How do I do this?
 
Physics news on Phys.org
What do you mean by 'the nth sequence'? You have given a 'for instance' but I don't even understand that case, let alone how you wish to generalise it.
 
There are algorithms to find the nth permutation for a given order (e. g. lexicographic - as it would appear in a lexikon). Example, another example.

The basic idea: Start with the first digit: How many permutations start with 0? Compare your number to that number and you get the first digit. Continue like that for all other digits.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 23 ·
Replies
23
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K