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 >
Wrap
Text File
|
1980-02-17
|
575b
|
23 lines
program ancestor2(output);
{ancestor algorithm using sets instead of boolean matrix}
const n = 20;
var i,j: integer;
r: array [1..n] of set of 1..n;
begin { j in r[i] = "i is a parent of j"}
for i := 1 to n do
if i mod 10 <> 0 then r[i] := [i+1] else r[i] := [];
writeln(wallclock);
for i := 1 to n do
for j := 1 to n do
if i in r[j] then
r[j] := r[i]+r[j];
writeln(wallclock);
for i := 1 to n do
begin write(' ');
for j := 1 to n do
if j in r[i] then write('1') else write('.');
writeln
end ;
writeln(wallclock)
end .