Created
October 1, 2017 00:58
Revisions
-
Aidan Fitzgerald created this gist
Oct 1, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ import java.util.BitSet; public class BitSort { public BitSet sort(BitSet bits) { // Count the number of ones: O(n) int numOnes = bits.cardinality(); // Overwrite the array with the ones first followed by the zeros bits.set(0, numOnes); bits.clear(numOnes, bits.size()); return bits; } }