Consider an array of only 1s and 0s. Write an algorithm that will separate all 1s and all 0s.
Efficeint Way: Try to do it in one parse of array.
Find the missing and repeating n..
Design time Textbox Extension for dynamic multi text box data entry location
What you have written above is a pass of Quick Sort.. This is just one of the solution.. If you see the time taken by your Algorithm is O(n)..with O(n) being the time complexity, the easiest solution is to count the zeros (or ones).. in first pass just count the number of 1's (say k) and in the second pass put (n-k) 0's and k 1's..