link mingle home | logged in as: guest | login/register| submit link


IndiaDiscuss.com : Social Bookmarkings and News Networking Site for India
interview_questions
Bookmarks
Sort a Binary Array in One pass
12
Votes

How would you sort an array that consists of only zeros and ones in only one pass?

saved under Yahoo Interview Questions by interview_questions

 
for(i = sizeof(A)/sizeof(int); i >= 0; --i) { if(A[i] == 1) { A[i] = A[9 - i]; A[9 - i] = 1; } }
comment by mr_101 on 2011-05-01 12:58:13
 



Enter the string above
 
IndiaDiscuss | Published News | Hot
Indian Social News and Links Network
IndiaDiscuss | Published News
Indian Social News and Links Network