Use a merge sort like procedure to count the number of inversions such that 0 appears after 1.
On Sat, Jun 23, 2012 at 11:34 AM, Gobind Kumar Hembram <gobind....@gmail.com > wrote: > Given an array containing sequence of bits (0 or 1), you have to sort > this array in the ascending order i.e. all 0' in first part of array > followed by all 1's. The constraints is that you can swap only the > adjacent elements in the array. Find the minimum number of swaps > required to sort the given input array. > > Example: Given the array (0,0,1,0,1,0,1,1) the minimum number of swaps > is 3. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.