Here is a solution somewhat based on 'parity':

The 10th student says white if she sees an even number of white hats and red if she sees an odd number of white hats (she will be the only one that could make a mistake). The 9th student now sees 8 hats in front of her. Say X of them are white. Now there are four possibilities:

The 9th student can figure out which case occurs and tell her correct hat color. From then on the students have to subtract the correctly guessed hats from the total and apply the even/odd reasoning again (using what the 10th student has said and counting the number of white hats in front of them).


You can also use this solution which is based on 'compression'

They decide to talk one after the other starting from the back. The one at the back (student 10) looks at the next one (student 9) and speaks out the color. Since one student is allowed to make a mistake, it's ok if it's wrong. Next one (student 9) repeats the color immediately if it's the same as next one's hat color, or waits for a couple of seconds and speaks out the color. So, the next one (student 8) will know if he is wearing the same color or different and he and the rest will follow the same rule until the first row student...

Note that, if the colors are mostly same, students will speak out quickly. But if they are mostly mixed, it will take longer to reveal the colors. (An interesting idea for those who are familiar with data compression)