My Math Forum  

Go Back   My Math Forum > Math Forums > Math

Math General Math Forum - For general math related discussion and news

Thanks Tree1Thanks
  • 1 Post By romsek
LinkBack Thread Tools Display Modes
January 11th, 2017, 12:49 AM   #1
AshBox's Avatar
Joined: Oct 2016
From: labenon

Posts: 33
Thanks: 4

Need to get the nth binary permutation.

This is the last missing piece I need to complete my compression algorithm, new one. 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?
AshBox is offline  
January 11th, 2017, 10:19 AM   #2
Senior Member
romsek's Avatar
Joined: Sep 2015
From: USA

Posts: 2,574
Thanks: 1421

If you are really using blocks of 4 bits I'd just pre-calculate everything and use a lookup table.

Given available memory these days I'd definitely do this for up to 8 bits, and probably do this for up to 16 bits.
Thanks from SophiaRivera007
romsek is offline  

  My Math Forum > Math Forums > Math

binary, nth, permutation

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
0.1 binary ungeheuer Algebra 3 October 26th, 2013 08:33 AM
A binary problem icemanfan Math Events 0 September 7th, 2013 12:12 PM
Binary composion Taladhis Abstract Algebra 5 January 17th, 2013 01:26 AM
Binary is hacked g_litched Algebra 0 March 23rd, 2010 08:53 AM
Fractal Binary ashesmi Number Theory 0 December 31st, 1969 04:00 PM

Copyright © 2019 My Math Forum. All rights reserved.