next up previous
Next: 5.2 Sort Bigram Frequencies? Up: 5.1 Sort Unigram Frequencies Previous: 5.1 Sort Unigram Frequencies

   
5.1.1 Sorting implies Swapping

In our attempted approach above, we said to ``sort letters according to their unigram frequencies''. How would we write a program to do that? We need to sort frequencies and keep track of the corresponding letters. Thus, we would use two parallel arrays: letters on top, frequencies on bottom. We would sort the frequencies, e.g. using selection sort, and every time we swap two frequencies, then we would swap the two corresponding letters.

Swapping will turn out to be extremely important throughout our attempts.



Thomas Yan
2000-05-01