I have an array sorted in ascended order. I want to replace the biggest m numbers found even positions in the array with 0.
My algorithm that I thought looks like this:
k=1;
for j=n:1  %%starting from last position to first
    if(rem(j,2)==0 && (k<=m))  %%checking if the position is even & not getting over m numbers
        B(j) = 0;
        k = k + 1;
    end
end
Can anyone point out why it is not working? Thank you!
 
     
     
    