[vox-tech] shell script challenge - Now MD5sum erratia

Samuel Merritt vox-tech@lists.lugod.org
Thu, 8 Aug 2002 12:12:38 -0700 (PDT)


Micah Cowan writes: 
> [snip]
> But it's a heluva lot better than running diff from one file to every
> other file - a factorial-time operation! :)

I think it's only quadratic-time. If you have N files, you need to diff
every possible pair of files to make sure that all the files are unique.
So,  you pick a file F, and compare it with all the other N-1 files. Since
you have to do this for all N files, and diff(file1, file2) is the same as
diff(file2, file1), that's only N(N-1)/2 diffs that have to be done. 

This is exactly like a question you see in math puzzle books sometimes: If
there's a group of N people and each person shakes hands with every other
person, how many handshakes are there?