[vox-tech] shell script challenge - Now MD5sum erratia
Micah Cowan
vox-tech@lists.lugod.org
Thu, 8 Aug 2002 13:40:20 -0700
Samuel Merritt writes:
>
> 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?
Sorry: I was thinking of sums and not multiplication (which is what
factorial is). I meant: N + N-1 + N-2 + ... + N-(N-1), which is
equivalent to N(N+1)/2.
-Micah