Modified 2 color sort problem i.e. you are given an array of integers containing only 0s and 1s.You have to place all the 0s in even position and 1s in odd position. And if suppose, no. of 0s exceed no. of 1s or vice versa then keep them untouched. Do that in ONE PASS and without taking extra memory (modify the array in-place).
For Example : Input Array: {0,1,1,0,1,0,1,0,1,1,1,0,0,1,0,1,1} Output Array: {0,1,0,1,0,1,0,1,0,1,0,1,0,1,1 ,1,1} Write a solid secure code for it. My solution: .....i thought of a solution ..but it takes 2 passes !! in first pass count all no. of zeros nd ones and in 2nd pass check whether no. of zeros > no. of 1 s and vice versa and accordingly assign values to the same input array ....can anybody give the solution in single pass?? .... -- Regards, $iva -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.