home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pascal / tests / ancestor2.p < prev    next >
Text File  |  1980-02-17  |  575b  |  23 lines

  1. program ancestor2(output);
  2. {ancestor algorithm using sets instead of boolean matrix}
  3.   const n = 20;
  4.   var i,j: integer;
  5.       r: array [1..n] of set of 1..n;
  6. begin { j in r[i] = "i is a parent of j"}
  7.   for i := 1 to n do
  8.     if i mod 10 <> 0 then r[i] := [i+1] else r[i] := [];
  9.   writeln(wallclock);
  10.   for i := 1 to n do
  11.     for j := 1 to n do
  12.       if i in r[j] then
  13.         r[j] := r[i]+r[j];
  14.   writeln(wallclock);
  15.   for i := 1 to n do
  16.   begin write(' ');
  17.     for j := 1 to n do
  18.       if j in r[i] then write('1') else write('.');
  19.     writeln
  20.   end ;
  21.   writeln(wallclock)
  22. end .
  23.