Sort a given binary array

Given an array of 0s and 1s which is indicate binary number. Our goal is to sort this array in effective manner. For example.

  Before Sort :
  0  1  1  0  1  0  1  1  0  1
  After Sort :
  0  0  0  0  1  1  1  1  1  1

Write an algorithm which is sort the binary array only once execute the loop. Here includes some effective solution.




Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved