Let denote a set of positive integers from to Sort them
For instance, if , then would give the sorted sequence where is the greatest integer in with three 's in its binary form.
If what is the number in the new sequence sorted as above?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
It appears there is no short,neat approach for this problem.
Counting Generalization
Let B j ( k ) denote the number of positive integers in S containing j number of 1 's. This can be expressed as B j ( k ) = ⎩ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎧ 0 ⌊ lo g 2 ( k ) ⌋ + 1 ( j lo g 2 ( k ) ) ( j ⌊ lo g 2 ( k ) ⌋ ) + B j − 1 ( k − 2 ⌊ lo g 2 ( k ) ⌋ ) j = 0 j = 1 j ≥ 2 , k = 2 n , n ∈ Z ≥ 0 j ≥ 2 , k = 2 n If j = 0 , clearly there is no positive integer that excludes 1 's.
If j = 1 , then the integers with singles are of the form 2 p , where 0 ≤ p ≤ ⌊ l o g 2 ( k ) ⌋ .
Otherwise, if 2 ≤ j ≤ ⌈ lo g 2 ( k ) ⌉ , the counting depends on the 2 -base-sum-representation of k and the value of j .
Subcase 1: If k − 2 ⌊ lo g 2 ( k ) ⌋ = 0 , then k = 2 n for a positive integer n . Then, we can freely count the number of j -tuple integers with lo g 2 ( k ) digits, which gives us ( j lo g 2 ( k ) ) .
Subcase 2: Otherwise, we determine the number of ( j − 1 ) -tuple integers for subset from 1 to k − 2 ⌊ lo g 2 ( k ) ⌋ > 0 . Then, count all j − t u p l e s with ⌊ lo g 2 ( k ) ⌋ digits.
Now, let's consider the leftmost digit, being 1 . If j − 1 = 1 , then we simply substitute ( k − 2 ⌊ lo g 2 ( k ) ⌋ ) back to B 1 . Otherwise, j − 1 ≥ 2 , which returns us to the subcases we consider. Repeat this until the sub B 's in B j ( k ) terminate.
Problem
The value k = 3 1 1 can be presented as 3 1 1 = 2 1 7 + 2 1 5 + 2 1 3 + 2 1 2 + 2 9 + 2 8 = 2 7 + 2 6 + 2 5 + 2 4 + 2 3 + 2 + 1 or the binary representation 1 0 1 0 1 1 0 0 1 1 1 1 1 1 1 0 1 1 2 . Since we are interested in finding the integer in the ordered set, compute the total number of integers in binary form, starting from j = 1 . Notice that the values in each lo g 2 are in fact base- 2 exponents in decreasing order from the sum.
So p = 1 ∑ 8 B p ( k ) = 8 8 0 4 7 . So we look at the last of the first 8 8 5 7 4 − 8 8 0 4 7 = 5 2 7 integers with nine 1 's. Digit-chasing, we have 1 1 1 0 1 1 1 1 1 0 0 1 0 2 , which is equivalent to the integer 7 6 6 6 .