It will work because we need to swap only adjacent elements. So we do a sweep from left to right finding the number of ones encountered to the left of a zero when we find a zero. We keep adding the number as we sweep the entire length.
On Sat, Jun 23, 2012 at 1:14 PM, deepikaanand <swinyanand...@gmail.com>wrote: > @saurabh..wat array r u getting finally....is it all 1's or in sorted > order for the input > int a[8]={1,1,1,0,1,0,1,1}; > > -- > 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.